Class MFPPush

MFPPush

Description:
IBM® MobileFirst® Platform provides a number of methods for supporting push notifications. Push notifications are supported on iOS and Android devices.

Method Summary
Method Attributes Method Name and Description
 
backgroundJobDone(id, result)
Completes the background job after receving the silent notification.
 
getSubscriptions(success, failure)
Retrieves all the subscriptions of the device
 
getTags(success, failure)
Retrieves all the available tags of the application
 
initialize(success, failure, timeout)
Initializes MFPPush instance.
 
isPushSupported(success, failure)
Checks whether Push Notification is supported on the device
 
registerDevice(options, success, failure)
Registers the device with the push service
 
Registers the callback method used for receiving the notifications
 
subscribe(tags, success, failure)
Subscribes the device to the given tags
 
unregisterDevice(success, failure)
Unregisters the device from the push service
 
unsubscribe(tags, success, failure)
Unsubscribes the device from the given tags
Method Detail
backgroundJobDone
backgroundJobDone(id, result)
Completes the background job after receving the silent notification. This API is applicable for iOS environment. When the silent notification arrives and the background job is completed, need to call this method to notify that the background job is completed.
Parameters:
id - Mandatory string. The callback-id received as part of notification properties
result - Optional. The result of background activity. A negative number indicates failure, zero tells no data and positive number tells the data downloaded.

getSubscriptions
getSubscriptions(success, failure)
Retrieves all the subscriptions of the device
Parameters:
success - Mandatory function. The callback function that is invoked with array of subscribed tags
failure - Mandatory function. The callback function that is invoked if the call fails

getTags
getTags(success, failure)
Retrieves all the available tags of the application
Parameters:
success - Mandatory function. The callback function that is invoked with array of tags of the application
failure - Mandatory function. The callback function that is invoked if the call fails

initialize
initialize(success, failure, timeout)
Initializes MFPPush instance. This is required for the client application to connect to MFPPush service with the right application context. This API should be called first before using other MFPPush APIs.
Parameters:
success - Mandatory function. The callback function that is invoked if the initialization is successful
failure - Mandatory function. The callback function that is invoked if the initialization fails
timeout - Optional. An integer value, denoting the timeout (in milliseconds) for all the requests made to the Push service

isPushSupported
isPushSupported(success, failure)
Checks whether Push Notification is supported on the device
Parameters:
success - Mandatory function. The callback function that is invoked if the call is successful
failure - Mandatory function. The callback function that is invoked if the call fails

registerDevice
registerDevice(options, success, failure)
Registers the device with the push service
Parameters:
options - Mandatory. ios: { alert: boolean, badge: boolean, sound: boolean, categories: Object[] } android: {} phoneNumber: String where phoneNumber - Phone number to receive the SMS based notifications alert - To enable displaying alert messages badge - To enable badge icons sound - To enable playing sound categories - iOS8 interactive notification categories for example, { ios: { alert: true, badge: true, sound: true, categories: [{ //Category identifier, this is used while sending the notification. id : "poll", //Optional array of actions to show the action buttons along with the message. actions: [ { //Action identifier id : "poll_ok", //Action title to be displayed as part of the notification button. title : "OK", //Optional mode to run the action in foreground or background. 1-foreground. 0-background. Default is foreground. mode: 1, //Optional property to mark the action button in red color. Default is false. destructive: false, //Optional property to set if authentication is required or not before running the action.(Screen lock). //For foreground, this property is always true. authenticationRequired: true }, { id : "poll_nok", title : "NOK", mode: 1, destructive: false, authenticationRequired: true } ], //Optional list of actions that is needed to show in the case alert. //If it is not specified, then the first four actions will be shown. defaultContextActions: ['poll_ok','poll_nok'], //Optional list of actions that is needed to show in the notification center, lock screen. //If it is not specified, then the first two actions will be shown. minimalContextActions: ['poll_ok','poll_nok'] }] }, android: { }, phoneNumber: "999999999" }
success - Mandatory function. The callback function that is invoked if the registration is successful
failure - Mandatory function. The callback function that is invoked if the registration fails

registerNotificationsCallback
registerNotificationsCallback(callback)
Registers the callback method used for receiving the notifications
Parameters:
callback - Mandatory function. The callback function that receives the notification

subscribe
subscribe(tags, success, failure)
Subscribes the device to the given tags
Parameters:
tags - Mandatory. Array of tags
success - Mandatory function. The callback function that is invoked if the subscription is successful
failure - Mandatory function. The callback function that is invoked if the subscription fails

unregisterDevice
unregisterDevice(success, failure)
Unregisters the device from the push service
Parameters:
success - Mandatory function. The callback function that is invoked if the unregistration is successful
failure - Mandatory function. The callback function that is invoked if the unregistration fails

unsubscribe
unsubscribe(tags, success, failure)
Unsubscribes the device from the given tags
Parameters:
tags - Mandatory. Array of tags
success - Mandatory function. The callback function that is invoked if the unsubscription is successful
failure - Mandatory function. The callback function that is invoked if the unsubscription fails

© Copyright IBM Corp. 2011, 2016.