How can I implement pushwoosh on intel xdk for an android app. Is there a step by step tutorial on it online. I have put the below code onto the index page, I have added the plugin, built the app and installed it on my phone but push notifications are not going through. Please help
<script>
function onDeviceReady() {
if( navigator.splashscreen && navigator.splashscreen.hide ) { // Cordova API detected
navigator.splashscreen.hide() ;
}
if( window.intel && intel.xdk && intel.xdk.device ) { // Intel XDK device API detected, but...
if( intel.xdk.device.hideSplashScreen ) // ...hideSplashScreen() is inside the base plugin
intel.xdk.device.hideSplashScreen() ;
}
initPushwoosh();
}
document.addEventListener("deviceready", onDeviceReady, false) ;
function initPushwoosh()
{
var pushNotification = cordova.require("com.pushwoosh.plugins.pushwoosh.PushNotification");
//set push notification callback before we initialize the plugin
document.addEventListener('push-notification', function(event) {
//get the notification payload
var notification = event.notification;
//display alert to the user for example
alert(notification.aps.alert);
//clear the app badge
pushNotification.setApplicationIconBadgeNumber(0);
});
//initialize the plugin
pushNotification.onDeviceReady({pw_appid:"****-****"});
//register for pushes
pushNotification.registerDevice(
function(status) {
var deviceToken = status['deviceToken'];
console.warn('registerDevice: ' + deviceToken);
},
function(status) {
console.warn('failed to register : ' + JSON.stringify(status));
alert(JSON.stringify(['failed to register ', status]));
}
);
//reset badges on app start
pushNotification.setApplicationIconBadgeNumber(0);
}
</script>
I just implemented this yesterday as well and it works fine. Here's what I did to make it easy.
In the index.html file I added these scripts
I put them in the body not the header. Then added this line to my init function under deviceready: document.addEventListener("deviceready", initPushwoosh, true);
That's it. It worked. I do have problems with it initializing each time but other than that it works.