How exactly do I get push tokens from a Live Activity that was started remotely?

In iOS 17.2+, we have a new feature that lets you use a push notification to start a Live Activity. The docs mention this:

While the system starts the new Live Activity and wakes up your app, you receive the push token you use for updates.

How exactly does this work?

I don’t see any listeners/delegate methods that trigger when you receive a start event. Since I need to extract the push tokens from a specific instance, how do I get that instance?

I can call Activity<MyType>.activities to see all running Live Activities, but assuming my end user has multiple instances running, how do I locate the instance that was started remotely?

Replies

Just to follow up here in case anyone is still wondering, any Live Activity that gets started, either locally in Swift or remotely via a push-to-start notification, will trigger activityUpdates as well as pushTokenUpdates. As long as you have these streams being observed in your code, the system should automatically wake your app up to trigger them anytime.

  • yeah activityUpdates should trigger, but this does not address the issue of retrieving the pushToken when starting an Activity remotely while the app is closed, since the Task listening to activityUpdates would not be running at that point in time

Add a Comment

@JerielNg pushTokenUpdates are not received until the user has given the permission by allowing LiveActivities in the lock screen. Once the permission is provided with allow/always allow, pushTokenUpdates are triggered with valid push token. Are you facing a similar issue?