【问题标题】:Push notifications implemented in worklight are not received in an Android device when the device is closed当设备关闭时,Android 设备中不会收到在 Worklight 中实现的推送通知
【发布时间】:2015-05-13 15:28:38
【问题描述】:

Android 设备在关机时不会收到在 Worklight 中实现的推送通知。当我打开设备时,通知栏中永远不会收到设备关闭时发送的推送通知。

CASE OF FAILURE TEST STEPS(设备关机时发送推送通知):

  1. 关闭设备

  2. 在设备关闭时向设备发送推送通知

  3. 打开设备电源

  4. 此 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
  1. 在服务器端(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(设备开机且应用处于后台时发送推送通知):

  1. 将应用设置为后台

  2. 向设备发送推送通知

  3. 推送通知完美显示在通知栏上。此 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


【解决方案1】:

将其写为答案,因为评论有字符限制...这不是您所遇到问题的完整答案

  • 当应用程序在前台时,通知栏不会显示消息,因为它会被应用程序使用。否则消息会转到通知栏。

  • 当设备断电或不在网络中时,在设备连接网络时发送消息。如果应用程序不在前台,它会传递到通知栏。

据我了解,“应用程序已关闭”一词是指应用程序已关闭或即使在后台也没有运行……对吗?

从我对示例所做的测试中,我看到通知确实被传递到通知栏。此外,我没有在推送通知示例中看到“FWLSE3002E:找不到资源”。为了能够更好地帮助您,您能否描述一下您使用推送通知示例解决此问题所遵循的步骤。

【讨论】:

  • 在我的帖子中,第二个 logCat 与应用程序相关,当它在后台并且设备处于打开状态时(我已经编辑了,因为我写错了)。术语“应用程序已关闭”是指设备已关闭。我现在要编辑这个问题,以重现我为弄清楚而采取的步骤。当我测试我的应用程序时,我在服务器端看到了“FWLSE3002E”,而不是示例。我正在使用 websphere 服务器。但是,对于示例应用程序,我看到了两种情况的随附 logCat。 ¿ 这可能是我正在测试的设备的特定问题吗?
  • 我必须补充一点,我已经用另一台 Android 设备进行了测试,它工作正常。发生故障的设备是 Sony Xperia M2 Android 4.4.2。我测试过的设备是 HTC Android 4.4.1。我已经在几台设备上测试过 Sony Xperia M2 Android 4.4.2 并且推送通知失败。您知道可能导致问题的原因吗,设备会收到来自其他应用程序的完美推送通知。
  • 我再次在 Android 5 上对此进行了测试并且工作正常……我确实看到在 logcat 中调用了 onUnhandled。让我确认一下……你是说这个问题只发生在 Sony Xperia M2 Android 4.4.2 上?
  • HTC mini Android 4.4.2 也出现该缺陷。在我们测试过的其他设备中,该场景有效。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-02-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-03
相关资源
最近更新 更多