Tag and Broadcast Notifications in Hybrid Applicationsimprove this page | report issue
Prerequisite: Make sure to read the Push Notifications in Hybrid Applications tutorial first.
Tag notifications are notification messages that are targeted to all the devices that are subscribed to a particular tag.
Tags represent topics of interest to the user and provide the ability to receive notifications according to the chosen interest.
Broadcast notifications are a form of tag push notifications that are targeted to all subscribed devices. Broadcast notifications are enabled by default for any push-enabled MobileFirst application by a subscription to a reserved
Push.all tag (auto-created for every device). Broadcast notifications can be disabled by by unsubscribing from the reserved
Tag Notifications configuration
Setting up tags
Tags are defined in the
API methods for tag notifications
WL.Client.Push.subscribeTag(tagName,options)- Subscribes the device to the specified tag name.
WL.Client.Push.unsubscribeTag(tagName,options)- Unsubscribes the device from the specified tag name.
trueif push notifications are supported by the platform, or
WL.Client.Push.isTagSubscribed(tagName)- Returns whether the device is subscribed to a specified tag name.
Common API methods for tag and broadcast notifications
WL.Client.Push.onMessage (props, payload)
This method is called when a push notification is received by the device.
- props - A JSON block that contains the notification 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
This method submits a notification based on the specified target parameters.
applicationId - (mandatory) The name of the MobileFirst application.
notificationOptions - (mandatory) A JSON block containing message properties.
For more information about tag and broadcast notifications, see the "tag-based notification" and "broadcast notification" topics in the user documentation.
Click to download the MobileFirst project.
The provided sample application demonstrates how to send a broadcast notification to the default auto-subscribed
The sample also demonstrates how to send notifications to two predefined tags, sample-tag1 and sample-tag2, to which the user can subscribe in the application.
Sending a notification
To test the application is able to receive a push notification you can perform one of the following:
- From MobileFirst Studio, right-click the adapter folder, select Call MobileFirst Adapter and:
- If selecting the "sendBroadcastNotification" procedure, provide the application ID and notification text in quotation marks.
- If selecting the "sendTagNotification" procedure, provide the application ID, notification text and tag name in quotation marks.
- The application ID can be determined from the
- If using the CLI:
Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.