Nabto Edge Push Notifications

Nabto Edge supports push notifications to mobile devices through integration with Firebase Cloud Messaging (FCM).

Sending FCM push notifications requires an FCM project ID and registration token. The project ID is retrieved when creating a Firebase project. The registration token uniquely identifies the mobile client the notification is destined for.

The client sends these configuration values to the device enabling it to generate push notifications for the particular client later. Nabto Edge makes it simple to send these configuration values from client to device (but any means of communication will do).

When an event occurs in the device triggering a push notification, the device uses the client configuration to generate the notification, and send it to the Nabto Edge Basestation to which it is attached.

The basestation uses Google’s FCM REST API to forward the notification to FCM. In turn, FCM responds to the basestation, which forwards the response back to the device. Finally, FCM delivers the notifcation to the mobile client.

The full flow is seen in the following:

Push State Management Using the IAM Module

The IAM module supports maintaining the information necessary to send FCM notifications, e.g. as shown in step 3 in the above figure. The IAM module is invoked by the Nabto Edge client using a Nabto Edge CoAP based API. These FCM helper functions in the IAM module simplifies FCM integration in the solution significantly.

Basic Information

The FCM project ID and registration token must always be passed to the device to be able to send notifications, this is done through the IAM module’s CoAP endpoint PUT /iam/users/:username/fcm where an object with ProjectId and Token is sent from the client to the device.

Notification Categories

In addition to this, the client can manage notification categories using the IAM module: These are strings configured in the device application, typically representing levels like CRITICAL, WARNING and INFO.

The client application can query the configured set of categories in the device using the IAM module’s GET /iam/notification-categories endpoint. The client can then set for which categories notifications should be received using the IAM CoAP PUT /iam/users/:username/notification-categories endpoint.

Later, when the device issues a notification, it can compare the notification categories of users on the device with the category of the event triggering the notification. So e.g. only users subscribing to INFO category notifications will get notified.

The categories are simply a set of strings and only used by the application itself. The IAM framework just checks that any categories set by the user are valid as defined by the device configuration. The Simple Push example demonstrates how to use categories to issue a push notification only to relevant subscribers.

Building an FCM based Nabto Edge Push Solution

Assuming a device configuration in the Nabto Cloud Console is created as discussed here, enabling push notifications then requires the following additional steps be performed:

  • Creating and configuring a Firebase project using our guide.
  • Integrating FCM in the client
  • Integrating push notifications in the device application

To try push notifications through Nabto Edge, the get started example comes with these steps completed and ready to run.