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}
Post
Replies
Boosts
Views
Activity
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)")
}
}
}
}
After downloading Xcode 15.1 RC I can get it to work on my device (updated with the latest beta), still not working in the simulator.