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);
}
出於某種原因,我的用戶數據是不確定的。什麼可能導致這個問題?
謝謝。