【发布时间】:2015-05-04 15:30:10
【问题描述】:
如何在英特尔 xdk 上为 Android 应用程序实现 pushwoosh。网上有没有分步教程。我已将以下代码放在索引页面上,添加了插件,构建了应用程序并将其安装在我的手机上,但推送通知没有通过。请帮忙
<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>
【问题讨论】:
标签: cordova push-notification phonegap-plugins intel-xdk pushwoosh