Created
June 26, 2014 19:25
-
-
Save mayroncachina/11a510ca3ac45078c093 to your computer and use it in GitHub Desktop.
Pushwoosh Phonegap (Android/IOS)
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
var pushNotification; | |
document.addEventListener("deviceready", onDeviceReady, false); | |
// device APIs are available | |
function onDeviceReady() { | |
initPushwoosh(); | |
} | |
function initPushwoosh() { | |
var pushNotification = window.plugins.pushNotification; | |
pushNotification.onDeviceReady(); | |
//appname = Nome do APP no site pushwoosh | |
//appid = Id do APP no site pushwoosh | |
//projectid = id do projeto no Google Developer Console - https://console.developers.google.com/ | |
pushNotification.registerDevice({ alert:true, badge:true, pw_appid:"XXXXX-XXXXX", appname:"MY_APP", projectid: "XXXXXXXXXXXX", appid : "XXXXX-XXXXX" }, | |
function(status) { | |
var pushToken = status; | |
console.warn('push token: ' + pushToken); | |
}, | |
function(status) { | |
navigator.notification.alert(JSON.stringify(['failed to register ', status])); | |
} | |
); | |
document.addEventListener('push-notification', function(event) { | |
var title = event.notification.title; | |
var userData = event.notification.userdata; | |
if(typeof(userData) != "undefined") { | |
console.warn('user data: ' + JSON.stringify(userData)); | |
} | |
navigator.notification.alert(title); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment