iOS 16 Live Activities Lock Screen widget

Good morning,

if I understood correctly, Live Activities will come on a later iOS 16 update and are not present on the current iOS 16 beta. I think that might explain the lack of documentation on the subject.

What I'd like to understand is what could be the best path to take to make sure we're prepared to build a Lock Screen widget with Live Activities.

Is a Home Screen widget a good starting point?

Does anyone know?

Can an Apple engineer shine some light into the topic?

Thank you

Answered by Technology Evangelist in 721773022

Live Activities and the ActivityKit framework are now available in iOS 16 beta 4. An announcement has been posted on News and Updates describing some of the details of the feature, as well as App Store submission.

Please refer to the ActivityKit framework documentation, as well as the “Displaying live data on the Lock Screen with Live Activities“ documentation article for implementation details.

I asked the same thing during WWDC22 Labs and the API behavior and design is pretty much on lock down.

Taking hints from the system and the use cases that Apple has demonstrated, a package delivery, a sports event score change, a ride share service, these are all things that seem to be remote server updated. Meaning the phone can't do them on their own. Maybe you could do a conference planner/scheduler Live Activity that is all locally cached, but the use cases were telling to me. I have to imagine it will look like WidgetKit but have some aspect of content-available push that maybe goes right to your widget / live activity extension. Or to your app and then reload timeline if truly like widget kit.

I'd also bet that just like widgets on home and Lock Screen, Live Activities will be 100% SwiftUI for visuals. So my vote goes to learning "systemMedium" widget family, and SwiftUI. If you make a systemMedium Home Screen widget visually, hopefully it would be reusable for your live activity view.

Out of curiosity, what is your use case? How often would you want to refresh the live activity? This was also something I talked about in my lab, trying to get info on refresh policies--nothing :) Guess we will have to wait. I was encourage to #filefeedback on my ideas for Live Activities so Apple can see what we want to build.

It looks like Live Activities is a combination of push notifications (initiated locally or remotely) into a single widget-like notification. So updates are triggered with notifications and the element itself will more likely act as a widget. It is unclear if button elements are allowed for direct control (as we see in music activity). If not then it's pure mid-size widgets, so I'd start with building a widget for your app.

Live Activities and the ActivityKit framework are now available in iOS 16 beta 4. An announcement has been posted on News and Updates describing some of the details of the feature, as well as App Store submission.

Please refer to the ActivityKit framework documentation, as well as the “Displaying live data on the Lock Screen with Live Activities“ documentation article for implementation details.

Is there some documentation on the errors for Live Activities? I've tried to create a sample app using the documentation article listed above. I get an error when I try to start a Live Activity. I'm not sure what it means, since I can't find any documentation on the errors.

Error requesting pizza delivery Live Activity The operation couldn’t be completed. (com.apple.ActivityKit.ActivityInput error 1.)

I have been testing the Live Activity API using the latest betas and the activity is saying it is started correctly, but is only displayed if it is the only widget in the extension. Can you have multiple widgets and live activities at the same time? I am also never getting a push token when starting the activity despite having push setup and being on an eligible machine according to the note in the doc. Has anyone gotten a live activity to properly display and/or a push token?

I have gotten it to show on a real device and have gotten push tokens now. It does seem like you are not able to start a live activity from the background which was not documented. If anyone has a way to do this that would be great to know!

let pushTokenString = String(deviceToken: self.statusActivity?.pushToken ?? Data())

extension String {
  public init(deviceToken: Data) {
    self = deviceToken.map { String(format: "%02x", $0) }.joined()
  }
}

→ POST https://api.sandbox.push.apple.com:443/3/device/800e9f97bb01fd62cf0ded1a546a3061c3dd09501068b8bedf05a1c4e23562c90c4c04e6c751b4b261687c03b4f87941959572c021bb3546bf441056a50ac65584eb790b10f35d15d7776da7268bbea7 apns-priority:10 apns-push-type:alert apns-topic:com.ustc.jerryliu.liveactivitiesdemo

{
  "aps" : {
    "event" : "update",
    "content-state" : {
      "homeScore" : 2,
      "estimatedEndTime" : 1660559974,
      "guestScore" : 2,
      "halfInfo" : "next"
    },
    "timestamp" : 1660556374
  }
}

← 400 apns-id:2E014A5B-EF1B-50AB-BA37-83A236C836F6

{ "reason" : "DeviceTokenNotForTopic" }

the push token not work,but the normal push word well Is there something wrong with the token?

How does a user enable/disable the feature? Is it a part of Focus as well?

Is there any way to load images from a URL (support updatable images) for Live Activity?

I know that from the doc "Each Live Activity runs in its own sandbox, and — unlike a widget — it can’t access the network or receive location updates." but supporting updatable images would be a very useful feature.

Also interesting that OneSignal mentioned here (https://onesignal.com/blog/using-ios-16-live-activities/) that "You can, however, still load images from a URL on demand into your Live Activity. The image URL could be part of the activity content that changes."

But passing URL & using AsyncImage doesn't work for me. Any ideas?

I am able to build this on simulator but when built on device facing crash in this line

let areActivitiesAllowed = ActivityAuthorizationInfo().areActivitiesEnabled

Using iOS 16 beta 4. Anyone facing same?

For simulator push token is nil. How can we test this?

Upgraded to iOS16 beta yesterday and trying this, facing the same crash. Cant surpass this. On Simulator how ever it doesnt happen. Any leads here?

ActivityAuthorizationInfo().areActivitiesEnabled -> Crashing

Has ActivityKit been removed? The links direct to WidgetKit or 404s.

Where is the document for ActivityKit? Xcode 14 RC also can't import ActivityKit

Is there a way to get iOS 16 Beta 6? I got Xcode beta 6 but simulator cannot be used to test getting a push token or test Live Activity with remote pushes

Set the apns-topic header field of the request you sent to APNs using the following format: <your bundleID>.push-type.liveactivity.

bundleID is main app's bundleID? or the widget's bundleID?

When creating an iOS live activity with Activity.request(attributes: , contentState: initialContentState, pushType: .token ) I get the error: The operation couldn’t be completed. (com.apple.ActivityKit.ActivityInput error 0.). but no error while I change pushType to nil I am sure I have requested Notification with [.sound, .badge, .alert] right

iOS 16 Live Activities Lock Screen widget
 
 
Q