Push Notifications

Ably can deliver native push notifications to devices using, amongst others, Apple’s Push Notification service and Google’s Cloud Messaging service. Native 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, native push notifications are commonly used to display visual notifications to users or launch a background process for an app in a battery efficient manner.

Beta notice

Ably’s push notification service is currently in beta. Please bear in mind:

  • Whilst the API we provide now is planned for our GA release, the API is subject to change. However, we will endeavour to only make changes to the API where necessary before we transition the service to GA (general availability).
  • The push service, as far as we are aware, is ready for production levels of usage. However, given the beta status, push notifications have not yet been stress tested under real-world production loads. As a result, you should expect some bugs. If you experience any problems, please get in touch and we’ll work as quickly as possible to help identify the problem and fix it.
  • The client libraries currently have varying levels of support for push notifications. Please refer to the push notification client library download section for details on how to use push on your devices and servers now.
  • Push notification statistics are currently disabled. Therefore, you are not currently charged for push notifications and and the push notification stats in your app dashboard will be zero. Please note that each push notification, when stats are enabled, will count as one message from a billing perspective. We plan to enable push statistics soon, get in touch if you need statistics now.
  • Documentation is not complete. However if you have any specific questions or recommendations in regards to how we can improve the documentation, please do get in touch

Delivering push notifications

Ably provides two models for delivering push notifications to devices:

Channel-based broadcasting

The model for delivering push notifications to devices over channels is intentionally very similar to how “normal” messages are delivered using Ably’s pub/sub channel. For example, a “normal” message published on an Ably channel is broadcasted immediately to all 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 native push notification.

Find out more about channel-based push notification broadcasting

Direct publishing

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

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

Find out more about direct push notification publishing

Activating a device and receiving notifications

Every device that will receive push notifications must activate itself with the local operating system or framework, and hook into the push notification services that the underlying platform provides. This functionality is platform specific and varies considerably across not just platforms, but also across the push services that operate on those platforms such as GCM and FCM, both of which are available on the Android platform.

The Ably client libraries aim to abstract away this complexity and platform specific behaviour by providing a consistent API for device activation, maintenance of the device registration, subscription to Ably channels for receiving push notifications, and of course for receiving the native push notifications themselves.

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.

Find out more about the push admin API.

Platform support

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

Apple Push Notifications
supported on all mobile devices running iOS, desktop devices running OS X and Safari
Google Cloud Messaging
supported on all Android and iOS devices, although we use GCM exclusively for Android message delivery
Firebase Cloud Messaging
supported on all Android and iOS devices, although we use FCM exclusively for Android message delivery

Downloading a client library with push support

As Ably’s push notification service is currently in beta, the client libraries currently have varying levels of support for push notifications.

See the list of client libraries with push notification support

Smart Notifications (currently in development)

Ably’s Smart Notifications offers a less intrusive and more effective way to notify your users with native iOS, Android and browser notifications. Instead of delivering “dumb” push notifications to your users when you wish to get their attention, Ably allows you to deliver messages based on a user’s connection state, their active device and their current context within your application. This means you can send less but more effective notifications to your users. Find out more.

How do Smart Notifications work?

Each Ably pub/sub channel can have one or more devices registered to it, and every device registered can be assigned a client identifier (i.e. they are an identified client in the Ably system).

When a message is published on a pub/sub channel, a smart notification payload and rules can optionally be included with the message. When the Ably service receives a message with a smart notification payload, it will do one of two things:

  • If the notification is configured as a “dumb” push notification, it will deliver the push notification to the relevant devices associated with the pub/sub channel. This is a common pattern with other vendors and it assumes that if the registered device app is not active, a visual push notification will be displayed, and if the app is open and active, the visual push notification will be suppressed. In the case of a data push notification, it will be always be delivered and no visual indicator is shown to the user.
  • If the notification is configured as a “smart” push notification, then Ably will process the rules for each smart notification in a user-centric way, such that the user is notified in the most effective way on the most relevant device based on their current context. For example, if a user has your mobile app installed but also uses your web app during office hours, and a notification is sent whilst the user is currently using the web app, then a visual notification can be shown only on the open web app, and the unnecessary duplicate push notification to their device can be suppressed. If however, after some configured time, the user has not responded to the message in the web app, a follow up native mobile push notification could be triggered automatically by Ably.

Find out why we believe smart notifications will be the next evolution of messaging.

Key features

  • Support for Android, iOS, Chrome, Firefox and Opera notifications at launch. Microsoft Azure and Safari Notifications planned.
  • Custom notification formats and badges for iOS and Android. Browsers simply receive the notification in a Web Worker which is in turn responsible for presenting a visual notification to the user.
  • 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.
  • Use-centric device registration allowing devices to be grouped by user.
  • Smart notification rules allow push notifications to be delivered to users on the right device at the right time. Simple workflow steps can be processed for each smart notification.
  • 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.

Get in touch if you’d like to be notified when Smart Notifications go into beta


API reference
Documentation

Get started now with our free plan

It includes 3m messages per month, 100 peak connections, 100 peak channels, and loads of features.

Create your free account