Live Activity Start Token not generating after certain days of usage. We have implemented Live Activity feature where the initial activity is launched by our backend. But to start that first live activity I need push to start token which is generating for few days but all of sudden after certain days it stops generating. Currently we are in development phase so we test it on multiple devices and multiple time we are doing install and uninstall.
STEPS TO REPRODUCE
- Install the app
- Start token gets generated which is sent to our server
- After certain duration server sends the first live activity using that token
- user opens the app then we receive the updated token and send that token to server
- server uses that updated token to further update the live activity.
All this works fine. But after a week of usage we are observing that we stop getting start token from APNS. Not sure where exactly the thing is breaking. We have tried with different devices and different bundle identifiers but behaviour is same for all.
func generateStartToken() { Task.detached { [weak self] in guard let self else { return } await self.observeActivityPushTokenAndState() for await data in ActivityKit.Activity<LiveActivityAttribute>.pushToStartTokenUpdates { let token = data.map { String(format: "%02x", $0) }.joined() print("Activity Start token: ", token) } } } func observeActivityPushTokenAndState() { Task.detached { for await activity in ActivityKit.Activity<LiveActivityAttribute>.activityUpdates { Task { for await tokenData in activity.pushTokenUpdates { let updatedToken = tokenData.map { String(format: "%02x", $0) }.joined() print("Activity Update token: ", updatedToken) } } Task { for await content in activity.contentUpdates { let updatedContent = content.state print("Activity Updated: ", updatedContent) } } } } }