0
我对开发android应用程序比较陌生。我正在使用pushwoosh和phonegap来尝试接收推送通知。我按照指示遵循了两个设置。我现在面临的问题是,当我从我的pushwoosh帐户发送消息时,弹出的警报不显示消息,但实际上显示为“null”。用pushwoosh + phonegap发送消息会产生“空”消息
下面来看看在控制台上的消息我得到:
05-13 20:08:26.568: D/dalvikvm(914): GC_CONCURRENT freed 273K, 21% free 3296K/4144K, paused 5ms+2ms, total 56ms
05-13 20:08:26.568: D/dalvikvm(914): WAIT_FOR_CONCURRENT_GC blocked 32ms
05-13 20:08:26.739: I/Choreographer(914): Skipped 37 frames! The application may be doing too much work on its main thread.
05-13 20:16:36.978: V/GCMBroadcastReceiver(914): onReceive: com.google.android.c2dm.intent.RECEIVE
05-13 20:16:36.978: V/GCMBroadcastReceiver(914): GCM IntentService class: com.arellomobile.android.push.PushGCMIntentService
05-13 20:16:36.978: V/GCMBaseIntentService(914): Acquiring wakelock
05-13 20:16:37.117: I/GCMIntentService(914): Received message
05-13 20:16:37.188: V/GCMBaseIntentService(914): Releasing wakelock
05-13 20:16:37.308: E/doOnMessageReceive(914): message is: {"message":"Hello","foregroud":true,"from":"41772830302","collapse_key":"do_not_collapse","onStart":false}
05-13 20:16:37.379: D/CordovaLog(914): user data: undefined
05-13 20:16:37.379: W/Web Console(914): user data: undefined at file:///android_asset/www/PushNotification.js:147
05-13 20:16:37.579: D/dalvikvm(914): GC_CONCURRENT freed 290K, 19% free 3395K/4144K, paused 5ms+3ms, total 106ms
你可以看到控制台显示原始消息“你好”。
下面来看看我的PushNotification.js:
function initPushwoosh()
{
var pushNotification = window.plugins.pushNotification;
pushNotification.onDeviceReady();
pushNotification.registerDevice({ projectid: "PROJECT_ID", appid : "APP_ID" },
function(status) {
var pushToken = status;
console.warn('push token: ' + pushToken);
},
function(status) {
console.warn(JSON.stringify(['failed to register ', status]));
}
);
document.addEventListener('push-notification', function(event) {
var title = event.notification.title;
var userData = event.notification.userdata;
console.warn('user data: ' + JSON.stringify(userData));
navigator.notification.alert(title);
});
}
function init() {
document.addEventListener("deviceready", initPushwoosh, true);
}
出于某种原因,我的用户数据是不确定的。什么可能导致这个问题?
谢谢。