Push Notifications

Ably can deliver push notifications to devices using, amongst others, Apple’s Push Notification service and Google’s Firebase Cloud Messaging service. Push notifications, unlike Ably’s channel based pub/sub messaging, do not require the device to maintain a connection to Ably, as the underlying platform or OS is responsible for maintaining its own battery-efficient transport to receive push notifications. Therefore, push notifications are commonly used to display visual notifications to users or launch a background process for an app in a battery-efficient manner.

Delivering push notifications


Push Notifications in Ably

As shown above, Ably provides two models for delivering push notifications to devices:

Direct publishing

Ably provides a REST API that allows push notifications to be delivered directly to:

  • Devices identified by their unique device ID
  • Devices identified by their assigned clientId
  • Devices identified by the recipient details of the push transport such as their unique registrationToken in the case of FCM, deviceToken in the case of APNS, or targetUrl and encryptionKey in the case of a Web device (experimental). This means is particularly useful when migrating to Ably with existing push notification target devices.

Find out more about direct push notification publishing

Channel-based broadcasting

The model for delivering push notifications to devices over channels is intentionally very similar to how messages are normally delivered using Ably’s pub/sub channel. For example, a normal message published on an Ably channel is broadcast immediately to all realtime subscribers of that channel. When broadcasting push notifications on channels, however, the process is the same with the exception that the subscribers (devices receiving push notifications) are registered in advance using our API and the message itself must contain an extra push notification payload that specifies the optional visual format and optional data payload of the push notification.

Find out more about channel-based push notification broadcasting

Activating a device and receiving notifications

Every device that will receive push notifications must register itself with the platform specific push notification service (APNs on iOS, FCM on Android). The Ably client libraries provide a consistent API for registration across all platforms, including device registration and receiving push notifications via Ably channels sent from other platforms.

Find out more about device activations and subscriptions.

Managing devices and subscriptions

Whilst the realtime client libraries provide APIs for a device to activate itself (via client.push) and subscribe for push notifications (via channel.push), those APIs are intentionally limited to actions pertaining to the device it is run on.

A separate and distinct push admin API is additionally provided in our client libraries specifically designed for use by your servers to facilitate managing and delivering push notifications across all of your registered devices. This API, amongst other things, includes features to manage registered devices, channel subscriptions and deliver push notifications directly. Currently the push admin API is available in our JavaScript, Ruby, Java/Android, PHP, Python, and iOS libraries. It is also available in our other libraries through the use of the request method, using the underlying API directly.

Find out more about the push admin API.

Platform support

Ably currently offers support for push notifications on the following platforms:

Apple Push Notifications
supported on all mobile devices running iOS and desktop devices running macOS
Firebase Cloud Messaging
supported on all Android and iOS devices, although we use FCM exclusively for Android message delivery
Experimental W3C Push API
experimental support for modern W3C compliant browsers (this does not include Apple’s Safari browser). You must request access to use this API.

Downloading a client library with push support

The following Ably client library SDKs provide support for activating and receiving push notifications:

Note: Our W3C Push API is still in development and should not be used in production applications. We welcome feedback and are particularly interested in which browsers you require support for. Get in touch for access to this experimental feature.

All Ably client library SDKs, that adhere to the v1.1 specification support, support push publishing and push admin functionality.

See the list of client libraries available for download

Key features

  • General Availability Support for Android and iOS
  • Experimental support for Chrome, Firefox and Opera. Apple’s Safari Notifications planned.
  • Custom notification formats and badges for iOS and Android. Browsers receive the notification in a Web Worker which is in turn responsible for presenting a visual notification to the user (this is an experimental feature).
  • Both visual notifications and data payloads can be sent to mobile devices.
  • Any number of mobile and browser devices can be registered on pub/sub channels. Each time a message is published with a push notification payload, Ably will ensure that all registered devices receive the push notification in near realtime.
  • Scale to millions of devices simultaneously by leveraging Ably’s global platform.
  • User-centric device registration allowing devices to be grouped by user (clientId)
  • Filters can be applied to notifications such as client ID, connection ID or device type, or alternatively you can push message directly to devices or users via our API.
  • Realtime metrics for your delivered and undelivered push notifications.
  • Error logging on a dedicated metachannel ([meta]log:push)

Tutorials

If you wish to see step by step instructions to set up, send and receive push notifications on your mobile devices, you can checkout our tutorials for iOS and Android, with both direct device registration and registration via server examples.


API reference
Documentation

Need help?

If you need any help with your implementation or if you have encountered any problems, do get in touch. You can also quickly find answers from our knowledge base, and blog.