我正在Android Phonegap应用中实现推送通知。当用户单击通知时,应用程序将打开,然后我要等到它加载后才显示消息。这是代码:
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
alert('in onDeviceReady');
},
goToMessage: function(){
alert('in goToMessage');
},
onNotificationGCM: function(e) {
alert('in the onNotificationGCM');
switch( e.event )
{
case 'message':
alert('in message');
document.addEventListener('load', this.goToMessage, false);
break;
default:
// alert('An unknown GCM event has occurred');
break;
}
},
当应用程序打开时,onDeviceReady()执行,我在switch语句中看到“in message”警告。但goToMessage()永远不会被执行。我做错了什么?