How do push notifications work with live activities?
Generated on 8/1/2024
1 search
Push notifications play a crucial role in updating live activities on Apple devices. Here's a detailed explanation of how they work with live activities:
-
Requesting a Push Token: When a live activity is started, the app requests a push token from ActivityKit. This token is unique for each live activity and is provided by the Apple Push Notifications service (APNs).
-
Server Communication: The app shares this unique push token with its app server. When there is an update, the server sends a push notification to APNs with the token and the payload.
-
Delivery to Device: APNs delivers the payload to the respective device, ensuring that the live activity is updated with the latest information.
-
Broadcast Push Notifications: For scenarios where a large number of people are viewing updates for the same event (e.g., a sports game), broadcast push notifications can be used. This allows the server to send a single push notification to APNs, which then delivers it to all devices subscribed to the channel. This method is efficient and ensures that everyone receives the update simultaneously.
-
Channel Management: Channels are used to manage broadcast push notifications. The lifecycle of a channel and the live activity are independent. Even if there are no active subscribers or everyone dismisses the live activity, the channel ID remains valid and can be used for future updates. However, the total number of active channels is limited, so it's important to manage and delete old or unused channels.
For more detailed information, you can refer to the session Broadcast updates to your Live Activities.
Relevant Sessions
Design Live Activities for Apple Watch
Starting in watchOS 11, Live Activities from your iOS app will automatically appear in the Smart Stack on a connected Apple Watch. Learn how to optimize the layout of your Live Activity for the wrist, and provide the right level of information and interactivity at the right time.
Bring your Live Activity to Apple Watch
Bring Live Activities into the Smart Stack on Apple Watch with iOS 18 and watchOS 11. We’ll cover how Live Activities are presented on Apple Watch, as well as how you can enhance their presentation for the Smart Stack. We’ll also explore additional considerations to ensure Live Activities on Apple Watch always present up-to-date information.
Broadcast updates to your Live Activities
With broadcast push notifications, your app can send updates to thousands of Live Activities with a single request. We’ll discover how broadcast push notifications work between an app, a server, and the Apple Push Notification service, then we’ll walk through best practices for this capability and how to implement it.