kony.notificationsettings Namespace
The kony.notificationsettings namespace provides the following API elements.
Functions
The kony.notificationsettings namespace provides the following functions.
This API helps you create an action that can be used with category.
Syntax
kony.notificationsettings.createAction (actionId, label, pspConfig);
Input Parameters
Parameter | Description |
---|---|
actionId [String] - Mandatory |
Specifies a unique ID to identify the action chosen by a user. |
label [String] - Mandatory | Specifies a label that needs to be associated with a action. |
pspConfig [JSObject] - Mandatory |
Specifies the configuration function. The parameters follow:
|
Example
/************************************************************************************* * Function:registerActions() * Description: Creates Actions and a Category. * Author: Kony *************************************************************************************/ function registerActions() { var accept = kony.notificationsettings.createAction({ "id": "Accept", "label": "Accept", "pspConfig": { "authenticationRequired": true, "destructive": true, "activationMode": kony.notificationsettings.ACTIVATION_MODE_FORWARDS, "visibleOn": kony.notificationsettings.BOTH } }); var reject = kony.notificationsettings.createAction({ "id": "Reject", "label": "Reject", "pspConfig": { "authenticationRequired": false, "destructive": false, "activationMode": kony.notificationsettings.ACTIVATION_MODE_FORWARDS, "visibleOn": kony.notificationsettings.BOTH } }); var decline = kony.notificationsettings.createAction({ "id": "Decline", "label": "Decline", "pspConfig": { "activationMode": kony.notificationsettings.ACTIVATION_MODE_BACKWARDS, "authenticationRequired": true, "destructive": false, "visibleOn": kony.notificationsettings.BOTH } }); var defaultActionContextArr = [accept, reject, decline]; var minimalActionContextArr = [accept, reject]; var categoryObj = kony.notificationsettings.createCategory({ "categoryId": "invitation", "actions": defaultActionContextArr, "pspConfig": { "minimalActions": minimalActionContextArr } }); //Using kony.notificationsettings.registerCategory var categoryArr = [categoryObj]; var registerCategory = kony.notificationsettings.registerCategory({ "categories": categoryArr, "pspConfig": { "types": [0, 1, 2] } }); }
Return values
This API returns action as a JavaScript object.
Platform Availability
- iOS
- Android
This API helps you create a category with a group of created actions.
Syntax
kony.localnotifications.createCategory (categoryId, actions, pspConfig:{minimalActions:[actions] , presentationOptions});
Input Parameters
Example
Example 1:
var categoryObj = kony.notificationsettings.createCategory({ "categoryId": "invitation", "actions": defaultActionContextArr, "pspConfig": { "minimalActions": minimalActionContextArr, "presentationOptions": [0, 1, 2] } });
Example 2:
/************************************************************************************* * Function:registerActions() * Description: Creates Actions and a Category. * Author: Kony *************************************************************************************/ function registerActions() { var accept = kony.notificationsettings.createAction({ "id": "Accept", "label": "Accept", "pspConfig": { "authenticationRequired": true, "destructive": true, "activationMode": kony.notificationsettings.ACTIVATION_MODE_FORWARDS, "visibleOn": kony.notificationsettings.BOTH } }); var reject = kony.notificationsettings.createAction({ "id": "Reject", "label": "Reject", "pspConfig": { "authenticationRequired": false, "destructive": false, "activationMode": kony.notificationsettings.ACTIVATION_MODE_FORWARDS, "visibleOn": kony.notificationsettings.BOTH } });
var decline = kony.notificationsettings.createAction({ "id": "Decline", "label": "Decline", "pspConfig": { "activationMode": kony.notificationsettings.ACTIVATION_MODE_BACKWARDS, "authenticationRequired": true, "destructive": false, "visibleOn": kony.notificationsettings.BOTH } }); var defaultActionContextArr = [accept, reject, decline]; var minimalActionContextArr = [accept, reject]; var categoryObj = kony.notificationsettings.createCategory({ "categoryId": "invitation", "actions": defaultActionContextArr, "pspConfig": { "minimalActions": minimalActionContextArr } }); //Using kony.notificationsettings.registerCategory var categoryArr = [categoryObj]; var registerCategory = kony.notificationsettings.registerCategory({ "categories": categoryArr, "pspConfig": { "types": [0, 1, 2] } }); }
Return Values
This API returns category as a JavaScript object.
Remarks
-
If the presentationOptions parameter is not set, it is considered as no options are set and onlineNotification will not be shown.
-
Only the mentioned values of presentationOptions must be passed as array.
-
The input values for presentationOptions must consist of an array of minimum one value to a maximum of all three values. These options are applicable for all kinds of notifications.
-
Onclick of notification banner triggers the onlinenotification callback when the app is in foreground/active state, whereas the offlinenotification callback is triggered when the app is in background/inactive state.
Platform Availability
- iOS
- Android
This API helps you register the created category with the application.
Syntax
kony.notificationsettings.registerCategory (categories, pspConfig);
Input Parameters
Parameter | Description |
---|---|
category [array] - Mandatory | Specifies the category objects that are to be registered. |
pspConfig [JSObject] - Optional | This parameter is applicable on iOS platform only. It specifies the platform specific configuration function. The arguments are:
NOTE: If the types are not passed or pspConfig is not defined, then all the notification types are registered by the API. NOTE: If the same API is invoked multiple times, the details of the last invoked call are updated. |
Example
/************************************************************************************* * Function:registerActions() * Description: Creates Actions and a Category. * Author: Kony *************************************************************************************/ function registerActions() { var accept = kony.notificationsettings.createAction({ "id": "Accept", "label": "Accept", "pspConfig": { "authenticationRequired": true, "destructive": true, "activationMode": kony.notificationsettings.ACTIVATION_MODE_FORWARDS, "visibleOn": kony.notificationsettings.BOTH } }); var reject = kony.notificationsettings.createAction({ "id": "Reject", "label": "Reject", "pspConfig": { "authenticationRequired": false, "destructive": false, "activationMode": kony.notificationsettings.ACTIVATION_MODE_FORWARDS, "visibleOn": kony.notificationsettings.BOTH } }); var decline = kony.notificationsettings.createAction({ "id": "Decline", "label": "Decline", "pspConfig": { "activationMode": kony.notificationsettings.ACTIVATION_MODE_BACKWARDS, "authenticationRequired": true, "destructive": false, "visibleOn": kony.notificationsettings.BOTH } }); var defaultActionContextArr = [accept, reject, decline]; var minimalActionContextArr = [accept, reject]; var categoryObj = kony.notificationsettings.createCategory({ "categoryId": "invitation", "actions": defaultActionContextArr, "pspConfig": { "minimalActions": minimalActionContextArr } }); //Using kony.notificationsettings.registerCategory var categoryArr = [categoryObj]; var registerCategory = kony.notificationsettings.registerCategory({ "categories": categoryArr, "pspConfig": { "types": [0, 1, 2] } }); }
Return Values
None
Remarks
Handling Local and Remote Notifications Callbacks:
- If the app is in the foreground state (app instance alive), an onlinecallback should be invoked.
- If the app is in background state (app instance alive or not alive), an offlinecallback should be invoked.
Platform Availability
Available on the iOS and Android platforms.
Once you set the kony.notificationsettings.pickTitleAndDescriptionFromPushPayload API as true, the Title and Description details of the payload are considered. By default, the Title and Description information of the payload are not respected.
Syntax
kony.notificationsettings.pickTitleAndDescriptionFromPushPayload (pickTitleAndDescriptionFromPushPayloadKey);
Input Parameters
Parameter | Description |
---|---|
pickTitleAndDescriptionFromPushPayloadKey [Boolean] - Mandatory | Set this input parameter as true to ensure that the Title and Description data of the payload are taken into consideration. |
Example
var pickTitleAndDescriptionFromPushPayloadKey = true; kony.notificationsettings.pickTitleAndDescriptionFromPushPayload (pickTitleAndDescriptionFromPushPayloadKey);
Remarks
The Boolean value that is passed in the pickTitleAndDescriptionFromPushPayloadKey input parameter is stored in Shared Preferences.
Platform Availability
- Android
You can use the kony.notificationsettings.setProperties API to set various properties of notifications that belong to a category.
Syntax
kony.notificationsettings.setProperties(categoryId, properties);
Input Parameters
Parameter | Description |
---|---|
categoryId | The category ID of the notification for which the priority is set. The value type of categoryId is String. |
properties |
The configuration object of the category. The value type of properties is JSON object. Currently, the JSON object contains the priority key. priority: A property for setting priority to the notification object related to a category. The value type of priority is constant. The priority key contains one of the following constants:
|
Example
propTable = {}; propTable.priority = constants.NOTIFICATION_PRIORITY_HIGH; kony.notificationsettings.setProperties({ categoryId: "invitation", properties: propTable });
Platform Availability
- Android
This API helps you to enable or disable notification badges for push/remote or local notifications that are only supported by Quantum Visualizer Framework. By default, the visibility of the notification badge is set to true on Android 8.0 devices.
Syntax
kony.notificationsettings.setShowBadge(notificationChannelName, showBadgeValue);
Input Paramters
Parameter | Description |
---|---|
notificationChannelName [String] - Mandatory | The following values are applicable for this parameter:
|
showBadgeValue [Boolean] - Mandatory | Set this value to false to disable the visibilty of the app notification badge. |
Example
var notificationChannelName = "pushNotification"; var showBadgeValue = false; kony.notificationsettings.setShowBadge(notificationChannelName, showBadgeValue);
Remarks
- You must call this API in preapp init, as the badge visibility can only be set after the first notification is received. This is because the channel creation is done after the first notification is initiated; once the channel creation is done, the visibility of the notification badge cannot be modified.
- Some launchers may not support the Notification Badge feature, even on devices with Android 8.0 and later.
Platform Availability
- Android 8.0 and later