Post

Replies

Boosts

Views

Activity

Reply to Issue starting Live Activities with ActivityKit push notifications
Regarding the payload, here is a working example: curl -v \ --header "authorization: bearer ${AUTHENTICATION_TOKEN}" \ --header "apns-topic: com.yourcompany.app.ios.push-type.liveactivity" \ --header "apns-push-type: liveactivity" \ --header "apns-priority: 10" \ --header "apns-expiration: 0" \ --data '{"aps":{"timestamp":'$(date +%s)', "event":"start", "content-state": {"currentValue":40000,"targetValue":50000}, "attributes-type":"MyActivityAttributes","attributes":{"currentValue":40000,"targetValue":50000},"alert":{"title":"Almost there!","body":"You have reached 75% of your goal!"}}}' \ --http2 https://api.development.push.apple.com:443/3/device/${PUSH_TO_START_TOKEN}
Dec ’23
Reply to Issue starting Live Activities with ActivityKit push notifications
The only way I found to get the token to update a live activity created through a push notification was to put the following code in my AppDelegate application didFinishLaunchingWithOptions method. I'm able to update a live activity created using push notifications using the token from pushTokenUpdates. But there is a major design flow IMO, since you can start a live activity without your app being running the following code will never get hit in that instance, and without a way to retrieve the update token from the server side there will be no way of updating the live activity... I must be missing something but the doc is not helpful in its current state. Task { // // Wait for newly created live activities // for await activityData in Activity<DailyGoalActivityAttributes>.activityUpdates { Task { // // Wait for the token needed to update a live activity using push notifications. // for await tokenData in activityData.pushTokenUpdates { let token = tokenData.map {String(format: "%02x", $0)}.joined() print("Push token: \(token)") } } } }
Dec ’23