Unable to start a live activity

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.

When testing you will want to enable frequent updates otherwise you run into situations like this.

To debug:

1)Plug the devices that aren’t showing the activities in to your computer and monitor with Console.app 2) Look for logs relating to your processes (target names), apd (the apns daemon) and the topic you are using for push. 3) filter by Budget and if you see : priority(0), budget(0) or running-not-visible, the system has decided to not show your activity.

Some reasons why this may occur:

  1. low battery mode
  2. bad data in the push(es)
  3. too many pushes in a short period of time

The only way to remedy this (because you cannot manually do this) is to wait for the system to add budget which can take up to 24 hours, and as you’ve seen, resetting the device doesn’t work.

There is also a chance the tokens you are using for testing aren’t matching the apns environment they should be used with. As example, tokens generated from test flight builds are actually production tokens and not sandbox as some would expect.

If there are specific pushes with timestamps and topics you can provide, I should be able to get more information, but Console.app will usually shed enough light to remedy any issues.

Hopefully this helps.

Unable to start a live activity
 
 
Q