Broadcast notifications in Hybrid applications

improve this page | report issue


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 by unsubscribing from the reserved Push.ALL tag.
For more information about broadcast notifications, see the user documentation.

Common API methods for tag-based and broadcast notifications

Client-side API:

WL.Client.Push.onMessage (props, payload)
  • props - A JSON block that contains the notifications properties of the platform.
  • payload - A JSON block that contains other data that is sent from the MobileFirst Server. It also contains the tag name for tag and broadcast notification. The tag name appears in the "tag" element. For broadcast notification, default tag name is Push.ALL.
WL.Client.Push.onMessage = function (props, payload) {
    alert("Provider notification data: " + Object.toJSON(props));
    alert("Application notification data: " + Object.toJSON(payload));
A callback function that is invoked when a push notification is received by the device. Set this function on a global JavaScript level. The Tag name Push.ALL is sent back in the payload parameter.

Server-side API:

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

Sample application

Click to download the Studio project. The provided sample application demonstrates sending a broadcast notification to the default auto-subscribed push.ALL tag. The sample also demonstrates sending notifications to two pre-defined tags, sample-tag1 and sample-tag2, to which the user can selects to subscribe to in the application. missing_alt missing_alt
Last modified on March 13, 2017