Where to retrieve Live activity update token that was started with ActivityKit push notifications using push-to-start token?

I can successfully start a Live Activity using push-to-start token, but in order to update the Live Activity i need another token as stated in the docs:

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

When the app is open, i can retrieve this update token and successfully update the Live Activity using this example code:

func observeActivityPushToken() {
        Task {
            for await activityData in Activity<LiveActivityAttributes>.activityUpdates {
                Task {
                    for await tokenData in activityData.pushTokenUpdates {
                        let token = tokenData.map { String(format: "%02x", $0) }.joined()
                        print("Push token: \(token)")
                    }
                }
            }
        }
    }

But when the app is closed, how/where do i manage to get this update token and send it to the server "when the system wakes up the app"?

You can use the same token token until the handler is called (which will wake your app in the background as well). activityData.pushTokenUpdates should have code to send the token to your server. Your present example just prints, which will not happen when your app is in the background.

You can also check if this is happening by using Console.app to monitor liveactivitiesd, your app and Widget extension processes which should let you know if things are working, and if not, the logs will shed light on why.

Rico

WWDR - DTS - Software Engineer

hi @nixhal are you able to fix it ? because I had a same case, I able to get a update token of a live activity that was started through push notification but when app is running but once app is quit or completely close how we will get update activity token @Engineer

Where to retrieve Live activity update token that was started with ActivityKit push notifications using push-to-start token?
 
 
Q