How do push works
Generated on 8/12/2024
1 search
Push notifications in the context of Apple's WWDC 2024 session "Broadcast updates to your Live Activities" work by leveraging the Apple Push Notification service (APNs) to deliver updates to users' devices. Here's a brief overview of how they function:
-
Push Token Request: When a live activity is started, the app requests a unique push token from ActivityKit, which is provided by APNs. This token is specific to each live activity on a device.
-
Server Communication: The app shares this push token with its server. When an update is needed, the server sends a push notification to APNs with the token and the payload.
-
Broadcast Push Notifications: For scenarios where many users are following the same event, such as a sports game, broadcast push notifications can be used. This method allows a single push notification to be sent to APNs, which then delivers it to all devices subscribed to a specific channel, identified by a unique channel ID.
-
Channel Management: Channels are used to manage broadcast push notifications. Each event or activity can have its own channel, and devices subscribe to these channels to receive updates. The lifecycle of a channel is independent of the live activity, meaning it remains valid even if there are no active subscribers.
-
Sending Updates: To send a broadcast push notification, you use the push notifications console to create a channel and send updates. The server can manage channels and send notifications directly to APNs using the new API.
For more detailed information, you can refer to the session Broadcast updates to your Live Activities (08:39) which covers how to send broadcast push notifications to update live activities on multiple devices at once.