2

我有一个通过 GCM 接收推送通知的简单应用程序。

我正在使用 Cordova + GCM 插件。我有一个显示通知的 JAVA 部分。JS 向服务器发送确认回执并在 SQlite DB 中记录消息。

应用程序启动后,一切正常。如果我清除内存或重新启动设备,设备仍会收到消息。Java 部分显示通知。但是 JS 函数调用 onMessage 不起作用(即设备不存储消息也不发送确认回执)。

这是我的两个场景的日志。对于某些未加载应用程序时调用 null,而不是 GCM_Event...

应用程序已加载,即使在后台:

01-26 16:19:03.958: V/GCMBroadcastReceiver(10546): onReceive: com.google.android.c2dm.intent.RECEIVE
01-26 16:19:03.958: V/GCMBroadcastReceiver(10546): GCM IntentService class: com.my.app.GCMIntentService
01-26 16:19:03.958: V/GCMBaseIntentService(10546): Acquiring wakelock
01-26 16:19:04.038: D/GCMIntentService(10546): onMessage - context: android.app.Application@4200bed0
01-26 16:19:04.063: D/GCMIntentService(10546): Dump json: {"message":"","ck":"42","cb":"9999","event":"message"}
01-26 16:19:04.063: V/GCMPlugin:sendJavascript(10546): javascript:GCM_Event({"message":"","ck":"42","cb":"9999","event":"message"})
01-26 16:19:04.068: V/GCMBaseIntentService(10546): Releasing wakelock

如果应用程序被卸载,一切都完全一样,除了最后一行:

01-26 16:19:04.063: V/GCMPlugin:sendJavascript(10546): javascript:null({"message":"","ck":"42","cb":"9999","event":"message"})
01-26 16:19:04.068: V/GCMBaseIntentService(10546): Releasing wakelock
4

0 回答 0