【发布时间】:2015-05-13 15:28:38
【问题描述】:
Android 设备在关机时不会收到在 Worklight 中实现的推送通知。当我打开设备时,通知栏中永远不会收到设备关闭时发送的推送通知。
CASE OF FAILURE TEST STEPS(设备关机时发送推送通知):
关闭设备
在设备关闭时向设备发送推送通知
打开设备电源
此 LogCat 显示,因此推送通知似乎正在到达设备。但是推送通知永远不会显示在通知栏中,也不会显示在应用程序中
LogCat:
05-14 14:39:12.180: V/GCMBroadcastReceiver(4829): onReceive: com.google.android.c2dm.intent.RECEIVE
05-14 14:39:12.180: V/GCMBroadcastReceiver(4829): GCM IntentService class: com.ibm.cio.be.android.navas.SmarterParking.GCMIntentService
05-14 14:39:12.180: V/GCMBaseIntentService(4829): Acquiring wakelock
05-14 14:39:12.210: V/GCMBaseIntentService(4829): Intent service name: GCMIntentService-DynamicSenderIds-1
05-14 14:39:12.230: W/com.worklight.common.Logger(4829): com.worklight.common.Logger.setContext(Context) must be called to fully enable debug log capture. Currently, the 'capture' flag is set but the 'context' field is not. This warning will only be printed once.
05-14 14:39:12.230: D/GCMIntentService(4829): GCMIntentService.onMessage in GCMIntentService.java:101 :: WLGCMIntentService: Received a message from the GCM server
05-14 14:39:12.230: W/GCMIntentService(4829): GCMIntentService.onMessage in GCMIntentService.java:108 :: Unable to update badge while received push notification, becasue failed to parse badge number null, badge must be an integer number.
05-14 14:39:12.250: D/GCMIntentService(4829): GCMIntentService.addToIntentQueue in GCMIntentService.java:123 :: WLGCMIntentService: App is not on foreground. Queue the intent for later re-sending when app is back on foreground.
05-14 14:39:12.250: V/GCMBaseIntentService(4829): Releasing wakelock
-
在服务器端(websphere),日志每两分钟显示一次此消息:
[5/14/15 8:36:26:581 EDT] 000002de BinaryDownloa E FWLSE3002E: The resource is not found. com.ibm.worklight.admin.common.util.exceptions.NotFoundException: FWLSE3034E: The application "ParkUP" was not found in project "ParkingApp".
设备似乎正在接收来自服务器的推送通知,但通知未显示在通知栏上。
CASE OF SUCCESS CASE(设备开机且应用处于后台时发送推送通知):
将应用设置为后台
向设备发送推送通知
推送通知完美显示在通知栏上。此 logCat 显示。
LogCat:
05-14 15:05:54.540: V/GCMBroadcastReceiver(9805): onReceive: com.google.android.c2dm.intent.RECEIVE
05-14 15:05:54.540: V/GCMBroadcastReceiver(9805): GCM IntentService class: com.ibm.cio.be.android.navas.SmarterParking.GCMIntentService
05-14 15:05:54.550: V/GCMBaseIntentService(9805): Acquiring wakelock
05-14 15:05:54.570: V/GCMBaseIntentService(9805): Intent service name: GCMIntentService-DynamicSenderIds-1
05-14 15:05:54.580: W/com.worklight.common.Logger(9805): com.worklight.common.Logger.setContext(Context) must be called to fully enable debug log capture. Currently, the 'capture' flag is set but the 'context' field is not. This warning will only be printed once.
05-14 15:05:54.580: D/GCMIntentService(9805): GCMIntentService.onMessage in GCMIntentService.java:101 :: WLGCMIntentService: Received a message from the GCM server
05-14 15:05:54.580: W/GCMIntentService(9805): GCMIntentService.onMessage in GCMIntentService.java:108 :: Unable to update badge while received push notification, becasue failed to parse badge number null, badge must be an integer number.
05-14 15:05:54.600: D/dalvikvm(1043): GC_CONCURRENT freed 3909K, 27% free 16903K/23012K, paused 26ms+13ms, total 212ms
05-14 15:05:54.600: D/GCMIntentService(9805): GCMIntentService.addToIntentQueue in GCMIntentService.java:123 :: WLGCMIntentService: App is not on foreground. Queue the intent for later re-sending when app is back on foreground.
05-14 15:05:54.600: V/GCMBaseIntentService(9805): Releasing wakelock
05-14 15:05:54.610: D/GCMIntentService(9805): GCMIntentService.onUnhandled in GCMIntentService.java:164 :: WLGCMIntentService: Showing notification for unhandled Message(alert=Sorry, your booking for tomorrow has been cancelled by the slot owner! Try again to book another slot. Good Luck!, badge=1, sound=null, payload={"alias":"myPush","custom":"data"})
05-14 15:05:54.620: W/ResourceType(1157): CREATING STRING CACHE OF 44 bytes
在这种情况下,除了调用 GCMIntentService.onUnhandled 之外,LogCat 与失败情况完全相同。
另外我想补充一点,如果我在设备无法访问互联网时测试发送推送通知,然后我让设备访问互联网,它也可以正常工作。
我已经测试了 worklight 教程中提供的示例,并且发生了同样的问题,但是在这种情况下,我没有使用 websphere 服务器进行测试,我正在使用本地 worklight 服务器进行测试,所以我没有请参阅服务器日志不适用于这种情况。
有没有人遇到过这个问题并找到了解决方案?
提前非常感谢您。
【问题讨论】:
-
锁定时关闭还是关机时关闭?
-
关闭或屏幕锁定是什么意思。
-
消息发送到GCM服务器时是否指定
time_to_live选项? -
您好,关闭时会失败,就像关机一样。当屏幕锁定时,它工作正常。
-
具体的 Worklight 版本和内部版本号?
标签: android ibm-mobilefirst google-cloud-messaging