How to send push notification

Generated on 10/4/2024

1 search

To send push notifications, particularly broadcast push notifications for live activities, you can follow these steps as outlined in the session "Broadcast updates to your Live Activities" from WWDC 2024:

  1. Create a Channel:

    • Enable the broadcast capability for your app via the developer portal.
    • Use the Push Notifications Console to create a new channel. This involves navigating to the channels tab and selecting "new channel" to configure it with the appropriate environment and message storage policy.
  2. Subscribe to Updates:

    • When a live activity is started, request a push token from ActivityKit. This token is unique for each live activity.
    • Share this token with your app server, which will use it to send updates.
  3. Send Broadcast Push Notifications:

    • Use the Push Notifications Console to send your first broadcast push. Select the channels tab, choose the channel you created, and click "new notification."
    • Fill in the necessary information, such as the channel ID, and use the payload builder to add content for the update.
    • Click send, and APNs will deliver the update to all devices subscribed to the channel.
  4. Channel Management:

    • Use the channel management API to manage the lifecycle of channels, including creating and deleting channels as needed.

For more detailed steps, you can refer to the session chapter on Send broadcast push notifications.