Create a Live Activity with ActivityKit & WidgetKit for iOS 16

Поделиться
HTML-код
  • Опубликовано: 13 окт 2024
  • Learn how to create a live lock screen widget for your iOS 16 app using WidgetKit and ActivityKit! This video uses Xcode 14 Beta 4, so expect changes over the next months.
    Sponsor Links:
    Try Adapty: adapty.io/
    Adapty iOS SDK: github.com/ada...
    Join the mobile devs community : / discord
    Documentation: developer.appl...
    WidgetKit Course: • WidgetKit Course
    👋 Links: flowritesco.de
    🛠 Forge: apple.co/3riG8MQ
    🚀 LaunchBuddy: apple.co/3iFcjjW
    Affiliate Links ❤
    📕 SwiftUI & Combine Books: www.bigmountai...
    🔬 Get Reports about your apps: appfigures.com...
    📊 Privacy focused analytics: dashboard.tele...
    💻 The most powerful mac app for developers: devutils.app/?...
    ☕️ Support me: ko-fi.com/flow...
    If you have any video suggestions please feel free to let me know by a comment.
    Get in contact via
    Twitter: / flowritescode

Комментарии • 47

  • @Tamloo1
    @Tamloo1 Год назад +2

    This was a great territorial and I was able to successfully implement a Live Activity in my app. Thank you for providing this. It was super short and to the point.

  • @MichaelRowe
    @MichaelRowe Год назад +1

    well done, I am looking at converting my widgets to Live Activities, glad I found this video. Keep it up!

  • @mikemikina
    @mikemikina 2 года назад +3

    Great video Flo! Thanks for sharing 🙌
    When you create this optional variable activity you don't need to set it to nil as it is nil by default, is it any different when it's @State? 🤔

    • @FloWritesCode
      @FloWritesCode  2 года назад +2

      You’re absolutely right, that isn’t needed! I just like to be very specific, that’s why I always specify the type and nil :D

  • @KartikeySingh-y9x
    @KartikeySingh-y9x Месяц назад

    How updateActivity function getting called ?, in video I can only see declaration and body of function

  • @DaveJacobseniOS
    @DaveJacobseniOS 2 года назад +1

    Great vid as always Flo!

  • @DairaEngineering
    @DairaEngineering 6 месяцев назад

    Hey Flo Could you please provide guidance on how to display real-time time in a widget ?

    • @FloWritesCode
      @FloWritesCode  6 месяцев назад

      I don't think you can really do that. My only idea would be looking at Text (date, style: ...) to see if there's an option for that.

  • @RahulJhaveri
    @RahulJhaveri Год назад +1

    Thank you for this video. This was very helpful. A question, how can we show a Live Activity update on the Home Screen on devices with no Dynamic Island?
    In Apple documentation, it states this can be done but I am not sure how to achieve this? Have you done this before? Thank you

    • @FloWritesCode
      @FloWritesCode  Год назад +1

      Hey Rahul - glad it was helpful.
      Are you referring to live activities on the lock screen for devices without the dynamic island? "Live home screen widgets" don't exist, unfortunately. Instead you can force iOS to update your home screen widgets through the WidgetCenter API in your main app.

  • @faengelm
    @faengelm Год назад +2

    @ 8:04 the ActivityConfureation looks different in Xcode as I have a dynamic Island option
    Can you show how that show be configured using the "(for: _.Type, content: (

    • @FloWritesCode
      @FloWritesCode  Год назад +1

      Yup, I have another video all about that topic: ruclips.net/video/AUOoalBwxos/видео.html

  • @franalarza8354
    @franalarza8354 Год назад +1

    Can I implement this in UIKit project? Thank for sharing!

    • @FloWritesCode
      @FloWritesCode  Год назад

      Yes you can! But the UI inside the Widget Extension has to be SwiftUI. The UI framework of your main app doesn't matter :)

  • @martcart
    @martcart Год назад +1

    Hello @Flo writes Code ,
    Its a great tutorial and i implemented this in new app its working fine but when i do the same code in my old Obj. C Project the live activity not going to be shown there is no error or warning i am getting what will be the issue can you assist me on that.

    • @FloWritesCode
      @FloWritesCode  Год назад

      Thank you. I have never worked with Objective-C so I can't help there, sorry.

  • @michaelheitz1808
    @michaelheitz1808 2 года назад +1

    Thank you so much for this video it was exactly the information I needed! I have question about the background color of the lock screen widget. I'm trying to change the background to a red, but maintain the signature apple semi-transparency. When I attempt to use .activityBackgroundTint(), it changes the color to red, but loses the semi-transparency. Is there a way to solve this?

    • @FloWritesCode
      @FloWritesCode  2 года назад +1

      Glad it was helpful! I don't think there is a system API for colored materials. You could play around with a ZStack with a color as the base layer. Then you could reduce the opacity of that color to match what you want to achieve.

  • @stefansturm
    @stefansturm Год назад

    Thanks for that… One question: Do you have any tutorials on updating the LiveActivity using URLSession Requests let’s say every 60 seconds?

    • @FloWritesCode
      @FloWritesCode  Год назад

      Are you referring to your app being in the foreground or background? You can only update a LiveActivity from your app while it's in the foreground. Alternatively you can update them using a push notification while your app is in the background. I haven't worked with that myself though, so I'm not sure how complex it is to set up.

    • @Harshsepi0l
      @Harshsepi0l Год назад

      @@FloWritesCode Hey Flo, i was wondering what the best way to set up a push notification is? I am looking at some of the documentation for ios 16.2 and I figured out a lot of the frontend for live activities, but it seems like apple deprecated a lot of the functions for the backend. I was wondering if you have experiment with any dynamic data to push to the notifications?

    • @Harshsepi0l
      @Harshsepi0l Год назад

      @@FloWritesCode also a lot of their documentation for push notifications does not seem to make sense to me and it would be nice if you made a video over dynamic backend data.

  • @AravindKaliyaperumal
    @AravindKaliyaperumal Год назад +1

    Hi, How to display the timer in minutes like 7 mins , 6 mins count down?

    • @FloWritesCode
      @FloWritesCode  Год назад

      I just had a look around the documentation, but I honestly don't know... Let us know if you figure it out!

  • @Arsh750
    @Arsh750 7 месяцев назад

    How can i create multiple live activities for a single app? Then how would we distinguish between say two activities, which one to call update and end after starting both?
    I have been trying to create instances but not successful

    • @FloWritesCode
      @FloWritesCode  6 месяцев назад +1

      I'm not sure, you'll have to dig into the documentation for that. I think it's pretty comprehensive though :)

  • @ShredzZ
    @ShredzZ 2 года назад

    Hi 👋 Do you think iOS development is good for full time freelancing? Lot of ppl saying that web is only best way to be freelancer.

    • @FloWritesCode
      @FloWritesCode  2 года назад +2

      I'm not doing any freelancing, but I'm sure there are plenty of people who live from it. It's probably easiest to learn about this on Twitter by following iOS developers (especially indies).

  • @EdwardMordrake618
    @EdwardMordrake618 2 года назад

    Thanks for the video. My question is; do user have to open the application, or will we be able to create the activity from remove notification? For example, on a live score activity, I would like to user get the activity automatically when the match starts, because I will send the remote notification for the activity to start.

    • @FloWritesCode
      @FloWritesCode  2 года назад

      Yes, that is possible! This video just shows how you can manage Activities from within the app, but you can also do this via push notifications. I would recommend you to have a look at the documentation, as this actually looks pretty nicely documented to me.

  • @printprogramming5303
    @printprogramming5303 2 года назад +1

    Very detailed 💌

  • @way2knowblog
    @way2knowblog 8 месяцев назад

    Can i use the same Live Activity in UIKit(SWIFT) project if any kindly share me the proper resources.

    • @FloWritesCode
      @FloWritesCode  7 месяцев назад +1

      Yup, this is the same setup for SwiftUI and UIKit. Just keep in mind that WidgetKit only supports SwiftUI.View, not UIKit.UIView.

  • @JerrysTechCorner
    @JerrysTechCorner 2 года назад

    Wow thanks for the great video!

  • @rizwansayyed5043
    @rizwansayyed5043 Год назад

    Hey can please HELP MEE!!!!!
    I want to create a lock screen widget and i create it. But i just need one additional thing i want that when clicked on widget the widget should not open the app (Which it is opening). It should run certain that like making a call to the api.
    Can please any one help me how i can achieve this task i have searched all over th
    e internet but didn't found any solution.
    PLEASE HELP MEE!!!!!

  • @chenwenzhong8875
    @chenwenzhong8875 Год назад +1

    How can I display a network image in Live Activity?

    • @FloWritesCode
      @FloWritesCode  Год назад

      Download the data using URLSession and turn it into a UIImage. You can then use it to create an Image.

    • @MinhHo-o8b
      @MinhHo-o8b 11 месяцев назад

      @@FloWritesCode Hello. I do work in react-native need show image url in live activity?. Help me! thx

  • @franalarza8354
    @franalarza8354 Год назад

    I don’t know how implement a Timer in live activities because when the widget is updated the counter returns to 0, can u help me?

    • @FloWritesCode
      @FloWritesCode  Год назад

      If you share your code I might be able to help :)

  • @Bfocused-tx9ir
    @Bfocused-tx9ir Год назад

    i get like 3 swift files when make a new widget

    • @FloWritesCode
      @FloWritesCode  Год назад

      Yes, the autogenerated files have changed. Their content is mostly the same as before though, except for a WidgetBundle, which you don't need to worry about :)

  • @ambilyy5856
    @ambilyy5856 Год назад

    Have anyone tried using stale date