The Kaa notification subsystem enables delivery of messages from the Kaa server to endpoints. The structure of the data that is carried by notifications is defined by the notification schema, which is configured on the Kaa server and built into Kaa endpoints. Please review the Kaa notifications design reference for more details.
This guide will familiarize you with the basic concepts of Kaa notifications and programming of the Kaa notification subsystem. It is assumed that you have already set up either a Kaa Sandbox or a full-blown Kaa cluster and that you have created at least one tenant and one application in Kaa. We also recommend that you review collecting endpoint profiles guide and using endpoint groups before you proceed with this guide.
The following diagram illustrates basic entities and data flows in scope of the notification management:
- Notifications are generated based on the notification schema created by the developer for the application
- The user or admin sends a notification using either Admin UI or REST API
This section provides guidance on how to configure notifications in Kaa.
The default notification schema installed for Kaa applications is empty. You can configure your own notification schema using the Admin UI or REST API. For the purpose of this guide, we will use a simple notification schema shown in the following code block.
Notifications in Kaa are organized into topics. Each topic may be associated with one or more endpoint groups. To subscribe to a specific notification, endpoints must belong to one or more endpoint groups that are associated with the corresponding notification topic.
Topics can be mandatory or optional. Mandatory topic notifications are delivered in an enforced manner. Optional topics require subscription. It is responsibility of the client code to add notification listeners and subscribe to optional topics.
Assuming that you have created custom endpoint groups from the Using endpoint groups guide, it would be logical to create and assign the following topics:
|Endpoint Group Name|
|Topic id||All||Android Froyo endpoints||Android endpoints||iOS 8 endpoints||3.0 RC1 QA group endpoints|
|iOS 8 notifications|
|All devices notifications|
This section provides code samples which illustrate practical usage of notifications in Kaa.
Get available topics
To get a list of available topics, do the following:
Subscribe to updates on available topics
To receive updates for the available topics list, add at least one listener as shown in the following code block (the number of listeners is not limited):
When subscription changes simultaneously for several topics, the following approach is recommended for performance reasons:
Default notification listener
There are two types of topic notification listeners: the default and topic specific. To receive notifications, add at least one default listener (the number of default listeners is not limited) as shown in the following code block. As a result, the listener will receive notifications from all topics (mandatory topics, as well as optional topics having been subscribed to).
Topic specific notification listener
To receive notifications on some specific topic (either mandatory or optional), you can use topic specific listeners (the number of listeners per topic is not limited) instead of the default listener. To create a topic specific listener, do the following:
Subscribe to optional topics
To receive notifications on some optional topic, at first subscribe to that topic as shown in the following code block:
You can work with a list of optional topics in a similar way as with a list of available topics.