Skip to main content
Push notifications notify user devices or browsers regardless of whether an application is open and running. They deliver information, such as app updates, social media alerts, or promotional offers, directly to the user’s screen. Ably sends push notifications to devices using Firebase Cloud Messaging or Apple Push Notification Service, and to browsers using Web Push. Push notifications don’t require a device or browser to stay connected to Ably. Instead, a device’s or browser’s operating system or web browser maintains its own battery-efficient transport to receive notifications.

Publishing methods

You can publish push notifications to user devices or browsers in two ways:

Direct publishing

Publishing directly sends push notifications to specific devices or browsers identified by unique identifiers, such as a deviceId or a clientId. This approach is akin to sending a personal message or alerts directly to an individual user’s device or browser, bypassing the need for channel subscriptions. Direct publishing excels in:
  • Targeted and personalized communications
  • User-specific alerts and notifications
  • Account notifications
  • Customized updates based on user actions

Publishing via channels

Publishing via channels uses a Pub/Sub model. Messages are sent to channels to which multiple devices or browsers can subscribe. When a message is published to a channel, all devices or browsers subscribed to that channel receive the notification. This approach is particularly powerful for:
  • Broadcasting to multiple users simultaneously
  • Group notifications
  • Topic-based alerts
  • Real-time updates to subscribers

Push notification process

Integrating push notifications into your application includes a few essential steps:
1
Configure
2
Configure your device’s or browser’s push notification service to operate with the Ably platform. This process includes inputting the necessary credentials into your Ably dashboard.
3
Activate
4
Activate devices or browsers for push notifications directly or via a server.
5
Direct activation enables devices or browsers to receive push notifications by obtaining a unique identifier. This is typically used when the application can directly handle device or browser registration.
6
Server activation delegates the activation process to your server rather than handling it directly on devices or browsers. This approach enhances security by minimizing the capabilities assigned to untrusted devices.
7
Publish
8
Publish push notifications using Ably via channels or directly.
9
Subscribe (for channel-based notifications)
10
If publishing via channels, devices or browsers must subscribe to those channels to receive notifications. Subscriptions can be made using:
11
  • deviceId: Subscribe devices or browsers directly using their unique identifier
  • clientId: Subscribe all devices or browsers tied to a particular user in one action
  • Push notification lifecycle

    The following diagram shows the push notification lifecycle:
    1. Publish: Your app or server publishes a push notification to Ably
    2. Process: Ably processes and packages the notification
    3. Forward: Ably forwards the packaged message to the appropriate push notification service (FCM, APNs, or Web Push)
    4. Deliver: The push notification service delivers the notification to target devices or browsers
    5. Display: The notification appears on the user’s device or browser screen

    Supported platforms

    Mobile devices

    • iOS: Via Apple Push Notification Service (APNs)
    • Android: Via Firebase Cloud Messaging (FCM)

    Web browsers

    • Chrome, Firefox, Edge: Via Web Push API
    • Safari: Via APNs for web

    Push admin API

    Ably’s push admin API is a set of functionalities designed for backend servers to manage push notification tasks:
    • Register devices or browsers for push notifications
    • Manage subscriptions to specific channels
    • Send push notifications directly to devices, browsers, or users

    Required capabilities

    Using the push Admin API requires explicit capabilities:
    • push-admin: Full API access, enables management of registrations and subscriptions for all devices or browsers
    • push-subscribe: Designates a client as a push target device or browser. Can only manage its own registration and subscriptions

    Error handling

    Monitor push notification errors using the [meta]log:push metachannel:

    Next steps

    Build docs developers (and LLMs) love