Push notifications
Send a Push notification to all devices having the same username
Through the following server-side javascript function you can notify via push notification the mobile app.
Syntax
var json = utils.sendPushNotification(
appId,
usernamesList,
title,
body,
actionIdToCall,
valueObject,
iOSBadgeCount
);
// the "json" result value is a String having the following format:
// [{...},...] with an element for each push notification sent (for each involved device id)Example
var usersEmails = ["email1@gmail.com","email2@gmail.com","emailN@gmail.com"]; //an array of registered user email accounts
var appMobileId = "MINION"; //the mobile application id
var notificationTitle = "Hello!"; //notification title
var notificationBody = "How did the cat get so fat?"; //notification body
var actionIdToCall = 123; //[optional] mobile actionId to call on the notification click if necessary
var valueObject = {"field1":"value1","field2":"value2","fieldN":"valueN"}; //[optional] map of <String, String> to use in the action id if necessary
var iOSBadgeCount = 1; //Total count of notification
utils.sendPushNotification(appMobileId, usersEmails , notificationTitle, notificationBody, 123, JSON.stringify(valueObject), iOSBadgeCount);When the push notification reaches the mobile application, it calls the optional actionId defined in the sendPushNotification injecting in the valueObject a parameter with the status of the push:
vo.notificationFieldStatus ="RECEIVED"
When the user clicks on the notification, the mobile app calls the optional actionId defined in the sendPushNotification injecting in the valueObject a parameter with the status of the push:
vo.notificationFieldStatus = "CLICKED"
This is an example of the optional actionIdToCall
Send a Push notification to a single device
Through the following server-side javascript function you can notify via push notification a specific device where the mobile app has been installed.
Syntax
Note that notificationOptions is mandatory for iOs Deice
Example
If you need to get the firebaseId, you can just append this scriptlet at the beginning of the the previous one, where the input data is the device id:
When the push notification reaches the mobile application, it calls the optional actionId defined in the sendSinglePushNotification injecting in the valueObject a parameter with the status of the push:
vo.notificationFieldStatus ="RECEIVED"
When the user clicks on the notification, the mobile app calls the optional actionId defined in the sendSinglePushNotification injecting in the valueObject a parameter with the status of the push:
vo.notificationFieldStatus = "CLICKED"
This is an example of the optional actionIdToCall
Mobile function
below some useful functions.
getUnreadNotificationsCount();
Returns the unread notifications count
setMenuBadges(menuFunctionId, count);
Sets the badge for the menu item by its functionId
resetUnreadNotifications();
Sets to zero the unread notifications count. After this, the methodgetNotificationsCount()will return zero. This method doesn’t update the menu item badge, you have to call
setNotificationBadge
If the type of menu includes the badge with the number of notifications, update the number of notifications
Last updated