Broadcast notifications in native Android applications

improve this page | report issue

Overview

Broadcast notification are in fact tag-based notification, where a subscription to a reserved tag, Push.ALL, is auto-created for every device. Broadcast notifications are thus notification messages that are targeted to all subscribed devices. Broadcast notifications are enabled by default for any push-enabled MobileFirst application. This ability can be disabled by unsubscribing the device from the reserved Push.ALL tag.
For more information about broadcast notification, see the topics about broadcast notification topic in the user documentation.

Common API methods for tag-based and broadcast notifications

Client-side API:

  • WLNotificationListener Defines the callback method to be notified when the notification arrives.
  • client.getPush().setWLNotificationListener(listener) This method sets the implementation class of the WLNotificationListener interface.
  • The onMessage(props,payload) method of WLNotificationListener is called when a push notification is received by the device.
    • props - A JSON block that contains the notifications properties of the platform.
    • payload - A JSON block that contains other data that is sent from MobileFirst Server. The JSON block also contains the tag name for tag-based or broadcast notification. The tag name appears in the "tag" element. For broadcast notification, the default tag name is Push.ALL.

Server-side API:

This method submits a notification that is based on the specified target parameters.
  • WL.Server.sendMessage(applicationId,notificationOptions)
    • applicationId - (mandatory) The name of the MobileFirst application
    • notificationOptions - (mandatory) A JSON block containing message properties
For a full list of message properties, refer to the WL.Server.sendMessage API in the API reference of the user documentation.

Sample application

Before running the application, check the adapter's PushAdapter-impl.js file and verify that the WL.Server.sendMessage() method use the correct application name. The correct application name can be determined from the id attribute in application-descriptor.xml. Click to download the Studio project. Click to download the Native project.
Last modified on April 18, 2016