forge.​pushwoosh

Class to interact with Pushwoosh Push Notifications plugin

Example
forge.internal.addEventListener("pushwoosh.pushReceived",
function (notification) {
alert('push received: ' + notification);
}
);

forge.internal.addEventListener("pushwoosh.registrationSuccess",
function (status) {
log('registered with token: ' + status['deviceToken']);
}
);

forge.internal.addEventListener("pushwoosh.registrationFail",
function (error) {
log('Failed to register: ' + error);
}
);

forge.pushwoosh.onDeviceReady({"pw_appid":"XXXXX-XXXXX", "gcm_id":"XXXXXXXXXXXX"});
forge.pushwoosh.registerDevice();

Expose the native API to javascript

Functions
onDeviceReady
onDeviceReady: function (
params,
success,
error
)

Call this first thing with your Pushwoosh App ID (pw_appid parameter) and Google Project ID for Android (gcm_id parameter)

Example
//initialize Pushwoosh with projectid: "GOOGLE_PROJECT_ID", gcm_id : "PUSHWOOSH_APP_ID". This will also trigger all pending push notifications on start.
forge.pushwoosh.onDeviceReady({"pw_appid":"XXXXX-XXXXX", "gcm_id":"XXXXXXXXXXXX"});
registerDevice
registerDevice: function (
success,
error
)

Call this to register for push notifications and retreive a push token via callbacks

Example
forge.pushwoosh.registerDevice();
unregisterDevice
unregisterDevice: function (
success,
error
)

Unregisters device from push notifications

Example
forge.pushwoosh.unregisterDevice();
setTags
setTags: function (
params,
success,
error
)

Call this to set tags for the device

Example

sets the following tags: "deviceName" with value "hello" and "deviceId" with value 10

forge.pushwoosh.setTags({tags : {deviceName:"hello", deviceId:10}},
function(status) {
forge.logging.log('setTags success');
},
function(status) {
forge.logging.log('setTags failed');
}
);

//setings list tags "tag1" with values (array) "item1", "item2"
forge.pushwoosh.setTags({tags : {"tag1" : ["item1", "item2"]}},
function (status) {
forge.logging.log('set tags success');
},
function(status) {
forge.logging.log('setTags failed');
}
);
getTags
getTags: function (
success,
error
)

Call this to get tags for the device

Example
forge.pushwoosh.getTags(
function (tags) {
log('tags loaded: ' + JSON.stringify(tags));
},
function(status) {
forge.logging.log('getTags failed');
}
);
getPushToken
getPushToken: function (
success,
error
)

Call this to get push token if it is available. Note the token also comes in "pushwoosh.registrationSuccess" function callback.

Example
forge.pushwoosh.getPushToken(
function (token) {
forge.logging.log('token : ' + token);
});
getHWID
getHWID: function (
success,
error
)

Call this to get Pushwoosh HWID used for communications with Pushwoosh API

Example
forge.pushwoosh.getHWID(
function (hwid) {
forge.logging.log('HWID : ' + hwid);
});
getRemoteNotificationStatus
getRemoteNotificationStatus: function (
success,
error
)

iOS only, Call this to get a detailed status of push notification permissions.

Returns array with the following items:

"enabled"

if push notificaions enabled.

"pushBadge"

badges permission granted.

"pushAlert"

alert permission granted.

"pushSound"

sound permission granted.

setApplicationIconBadgeNumber
setApplicationIconBadgeNumber: function (
params,
success,
error
)

iOS only, Call this to set the application icon badge

Example
forge.pushwoosh.setApplicationIconBadgeNumber({badge:10});
cancelAllLocalNotifications
cancelAllLocalNotifications: function (
success,
error
)

iOS only, Call this to clear all notifications from the notification center

setForegroundAlert
setForegroundAlert: function(
params,
success,
error
)

Set to true to disable automatic push handing in foreground By default is set to true on iOS and false on Android

Example
forge.pushwoosh.setForegroundAlert({alert:true});
setUserId
setUserId: function(
params,
success,
error
)

Set User indentifier. This could be Facebook ID, username or email, or any other user ID.  This allows data and events to be matched across multiple user devices.

postEvent
postEvent: function(
params,
success,
error
)

Post events for In-App Messages. This can trigger In-App message display as specified in Pushwoosh Control Panel.

Parameters
"event"

event to trigger

"attributes"

object with additional event attributes

Example
forge.pushwoosh.postEvent({event:"buttonPressed", attributes:{ "buttonNumber" : 4, "buttonLabel" : "banner" }});