Created
September 10, 2015 14:17
-
-
Save mayroncachina/8147c462b7967e129fa5 to your computer and use it in GitHub Desktop.
Pushwoosh code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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