I'm unable to get live activity to show up in my app so I started to play with the demo app Emoji Rangers.
The demo project initially only created a live activity in-app and then you're able to update it via the demo buttons.
I added the following code to have it be able to start a live activity from the backend:
func observePushToStartToken() { Task { for await data in Activity<AdventureAttributes>.pushToStartTokenUpdates { let token = data.map {String(format: "%02x", $0)}.joined() // Send token to the server print("got PUSHTOSTART TOKEN: (token)") }
} }
I get the token and then I use it to send this payload that should start the activity:
{ "aps":{ "timestamp":1743719911, "event":"start", "content-state":{ "currentHealthLevel":100, "eventDescription":"Adventure has begun!", "supercharged":true }, "input-push-token":1, "attributes-type":"AdventureAttributes", "attributes":{ "currentHealthLevel":100, "eventDescription":"Adventure has begun!", "supercharged":true }, "alert":{ "title":{ "loc-key":"%@ is on an adventure!", "loc-args":[ "Power Panda" ] }, "body":{ "loc-key":"%@ found a sword!", "loc-args":[ "Power Panda" ] }, "sound":"chime.aiff" } } }
But unfortunately I get an error when I send it: [AdventureAttributes] Error creating activity: NSCocoaErrorDomain (4865) The data couldn't be read because it is missing.
First step is to get this working, so I want to get your help in figuring out what I'm missing.