Skip to content

Instantly share code, notes, and snippets.

@mayroncachina
Created September 10, 2015 14:17
Show Gist options
  • Save mayroncachina/8147c462b7967e129fa5 to your computer and use it in GitHub Desktop.
Save mayroncachina/8147c462b7967e129fa5 to your computer and use it in GitHub Desktop.
Pushwoosh code
#config.xml
<gap:plugin name="com.pushwoosh.plugins.pushwoosh" version="3.4.2" />
#js
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
// Now safe to use device APIs
initPushwoosh();
}
function initPushwoosh()
{
var pushNotification = cordova.require("com.pushwoosh.plugins.pushwoosh.PushNotification");
//set push notifications handler
document.addEventListener('push-notification', function(event) {
var title = event.notification.title;
var userData = event.notification.userdata;
if(typeof(userData) != "undefined") {
alert('user data: ' + JSON.stringify(userData));
}
alert(title);
});
initialize Pushwoosh with projectid: "GOOGLE_PROJECT_NUMBER", pw_appid : "PUSHWOOSH_APP_ID".
//register for pushes
pushNotification.registerDevice(
function(status) {
var pushToken = status;
console.warn('push token: ' + pushToken);
//alert(status)
},
function(status) {
console.warn(JSON.stringify(['failed to register ', status]));
alert(JSON.stringify(['failed to register ', status]))
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment