Push notifications

Use the following methods to configure push notifications.

isStarted

Callback arguments: (bool isStarted)

Indicates whether Push has started. Push starts automatically if you set up all the keys in config.xml.

R1Push.isStarted(function (isStarted) {
    //...
});

setEnabled

Enable or disable R1Push.

R1Push.setEnabled(true);

isEnabled

Callback arguments: (bool isEnabled)

Indicates whether R1Push is enabled.

R1Push.isEnabled(function (isEnabled) {
    //...
});

getDeviceToken

Callback arguments: (String deviceToken)

Get the push identifier for the device. Can be null if R1Push not enabled.

R1Push.getDeviceToken(function (deviceToken) {
    //...
});

setBadgeNumber

Note: iOS only

Set application badge number.

R1Push.setBadgeNumber(2);

getBadgeNumber

Note: iOS only. For Android the callback will always be a 0 value.

Callback arguments: (int badgeNumber)

Get currently used badge number.

R1Push.getBadgeNumber(function (badgeNumber) {
    //...
});

setTags

Set tags for the device.

R1Push.setTags(["Tag1", "Tag2"]);

addTag

Add tag for the device

R1Push.addTag("Tag1");

removeTag

Remove tag from the device

R1Push.removeTag("Tag1");

getTags

Callback arguments: (Array tags)

Get the current tags.

R1Push.getTags(function (tags) {
    //...
});

Events

R1Push.deviceToken

Notify the push deviceToken has changed

document.addEventListener("R1Push.deviceToken", function(event) {
    // event.deviceToken
}, false);
R1Push.foregroundNotification

For iOS and Android: Notify when a push notification is recieved when the application is running in the foreground

For Windows Phone 8: Notify when a Toast notification is recieved when the application is running in the foreground

document.addEventListener("R1Push.foregroundNotification", function(event) {
    // event - object with full information about notification
    alert(event);
}, false);
R1Push.backgroundNotification

Only for iOS and Android! Notify when a push notification is received when the application is running in the background and the app is opened by this notification

document.addEventListener("R1Push.backgroundNotification", function(event) {
    // event - object with full information about notification
    alert(event.aps.alert);
}, false);
R1Push.foregroundHttpNotification

Only for Windows Phone 8: Notify when a Raw notification is recieved when the application is running in the foreground

document.addEventListener("R1Push.foregroundHttpNotification", function(event) {
    // event - object with full information about notification
    alert(event);
}, false);

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk