voltmx.localnotifications Namespace
The voltmx.localnotifications
namespace provides your app the ability to create and receive local, on-device notifications that do not rely on off-device information coming across a network. The voltmx.localnotifications namespace contains the following API elements.
Functions
The voltmx.localnotifications namespace contains the following functions.
voltmx.localnotifications.cancel
Cancels the specified notifications.
Syntax
voltmx.localnotifications.cancel(notificationId)
Input Parameters
Parameter | Description |
---|---|
notificationId | An array of notification IDs that selects the notifications to cancel. |
Example
Return Values
None
Platform Availability
Available on iOS and Android platforms.
voltmx.localnotifications.create
Creates a local notification.
Syntax
Input Parameters
Parameter | Description |
---|---|
notificationId | A string that specifies a unique ID for the notification. |
datetime | A string that specifies the date and time when the notification must be triggered. Must follow the unicode date, time, and Timezone pattern. |
message | A string that specifies the message for the notification. |
title | A string that specifies the title for the notification. |
categoryId | A string that specifies the category ID to associate this local notification with, or null in case no actions are to be displayed. |
pspConfig | An optional JavaScript object containing key-value pairs that set the platform-specific options. Used on iOS platform only. The following keys are supported. badge: An optional number that displays the number of notifications on the app icon. sound: An optional string that specifies the sound to play. For more information, see the Remarks section below. |
Example
Return Values
None
Remarks
To play a sound when a notification arrives, your app must specify the sound using the “sound” key in the JavaScript object contained in the pspConfig parameter. Your app must assign a sound file from the app’s main bundle. If the sound file is not available or the provided file name is incorrect, it will play a default sound from the system (voltmx.localnotifications.DEFAULT_SOUND
). To know the see file formats, click here
Platform Availability
Available on
- iOS (The voltmx.notificationsettings.registerCategory API must be called before the create API for it to work)
- Android
voltmx.localnotifications.getNotifications
Retrieves the pending local notifications.
Syntax
voltmx.localnotifications.getNotifications(notificationObjects)
Input Parameters
Parameter | Description |
---|---|
notificationObjects | An optional array of notification objects if there are pending notifications, or an empty array if there are not. This parameter is only used on iOS. |
Example
Return Values
None.
Platform Availability
Available on iOS and Android platforms.
voltmx.localnotifications.setCallbacks
Associates online and offline callbacks for local notifications.
Syntax
voltmx.localnotifications.setCallbacks(onlinenotification,offlinenotification)
Input Parameters
Parameter | Description |
---|---|
onlinenotification | A callback function that is invoked when the online notification is triggered. For more information, see the Remarks section below. |
offlineNotification | A callback function that is invoked when the offline notification is triggered. For more information, see the Remarks section below. |
Example
Return Values
None
Remarks
The callbacks that this function sets are invoked when notifications are raised by the underlying system. The online notification callback is involved when the application is running. The offline callbacks are invoked when the application is not running. This function should be called inside the post app init
event handler when your app starts.
The callback function in the onlinenotification parameter must have the following signature.
onlineNotificationCallback(actionID,notificationObject);
where actionId is a unique ID for the action, and notificationobject is a JavaScript object that contains platform-specific notification information.
The callback function in the offlinenotification parameter must have the following signature.
offlineNotificationCallback(actionID,notificationObject);
where actionId is a unique ID for the action, and notificationobject is a JavaScript object that contains platform-specific notification information.
Platform Availability
Available on iOS and Android platforms.