pushy icon indicating copy to clipboard operation
pushy copied to clipboard

iOS Live Activities

Open NachoSoto opened this issue 2 years ago • 7 comments

Apple just released Live Activities: https://developer.apple.com/documentation/activitykit/displaying-live-data-on-the-lock-screen-with-live-activities

This will allow servers to send push notifications directly to a live activity (as opposed to the app itself): https://developer.apple.com/documentation/activitykit/activity/pushtoken

I'm still catching up on the documentation, not sure if Pushy will need to support this in any way. It's possible that just using those tokens Pushy will work for this out of the box though.

NachoSoto avatar Jul 27 '22 18:07 NachoSoto

I spotted this in the docs:

Send push notifications to the Live Activity using the push token you stored on your server. It’s essential that you set the fields for the content-state key to match your custom Activity.ContentState type to ensure the system can decode the JSON payload and update the Live Activity.

I can't find any other documentation explaining where that key should be set, though. They do offer an example that makes it look like it should be in the aps section:

{
    "aps": {
        "timestamp": 1650998941,
        "event": "update",
        "content-state": {
            "driverName": "Anne Johnson",
            "estimatedDeliveryTime": 1659416400
        }
    }
}

…but I can't find any documented requirements about how it needs to be "shaped." My guess is that the payload docs will get updated shortly. I'll plan to act when there's more concrete information available.

jchambers avatar Jul 28 '22 00:07 jchambers

@jchambers I was able to get this to work today with the above payload. The topic is the main apps bundle ID + .push-type.liveactivity and the push-type is liveactivity

rlepinski avatar Aug 08 '22 23:08 rlepinski

Thanks! At this point, the concern isn't getting it to work so much as being confident that we haven't accidentally baked in some gotchas that we'd need to roll back later. I still think the right move is to wait for the documentation to catch up (it looks like it still hasn't), but I do hope to act on this soon.

jchambers avatar Aug 09 '22 12:08 jchambers

@jchambers I was able to get this to work today with the above payload. The topic is the main apps bundle ID + .push-type.liveactivity and the push-type is liveactivity

Thanks a lot for sharing, this helped a lot 🙏 Just curious, how did you find out about the postfix for the bundle identifier?

fxm90 avatar Aug 15 '22 19:08 fxm90

@fxm90 In the console logs I found a statement from APSCourier that listed my apps bundle id with the postfix

rlepinski avatar Aug 15 '22 20:08 rlepinski

Well, the docs still haven't been updated, and it's been more than a month. I think it might be time to just go for it soon.

jchambers avatar Sep 01 '22 02:09 jchambers

Just noticed they added some docs - https://developer.apple.com/documentation/activitykit/update-and-end-your-live-activity-with-remote-push-notifications. Doesn't look like the APNS payload docs have been updated yet but at least they have documented the topic and push type.

rlepinski avatar Sep 16 '22 15:09 rlepinski

I started working on Live Activities and needed support for sending push notifications, so I have created a draft PR (#990) with a base implementation for supporting Live Activities based on the few docs that are available, that seems to be working as of iOS 16.1 b2/b3

ifrins avatar Sep 28 '22 09:09 ifrins