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:

  1. 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).

  2. 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.

  3. Delivery to Device: APNs delivers the payload to the respective device, ensuring that the live activity is updated with the latest information.

  4. 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.

  5. 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

  1. Broadcast updates to your Live Activities
  2. Design Live Activities for Apple Watch
  3. Bring your Live Activity to Apple Watch