当设备关闭时,Android设备中不会收到在工作光中实现的推送通知

时间:2021-10-17 22:15:06

Push notifications implemented in Worklight are not received by an Android device when the device is powered-off. When I power-on the device, the push notification which was sent when the device was powered-off is never received in the notification bar.

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

CASE OF FAILURE TEST STEPS (push notification send when device is powered-off):

失败测试步骤的情况(设备断电时发送推送通知):

  1. Power-off the device

    关闭设备电源

  2. Send push notification to the device while it is powered-off

    在关闭电源时向设备发送推送通知

  3. Power-on the device

    打开设备电源

  4. This LogCat shows so the push notification seems to be arriving to the device. However the push notification never shows in the notification bar, neither in the application

    此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. In the server side (websphere), the logs shows this message every two minutes:

    在服务器端(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".
    

The device seems to be receiving the push notification from the server but the notification does not show on the notification bar.

设备似乎正在接收来自服务器的推送通知,但通知未显示在通知栏上。

CASE OF SUCCESS CASE (Push notification send when device is powered-on and app on background):

成功案例案例(设备启动时发送推送通知,背景上发送应用程序):

  1. Set the application on background

    在后台设置应用程序

  2. Send push notification to device

    向设备发送推送通知

  3. Push notification appears perfectly on notification bar. This logCat shows.

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

In this case, the LogCat is exactly the same as the failure case except for the GCMIntentService.onUnhandled being called.

在这种情况下,除了调用GCMIntentService.onUnhandled之外,LogCat与失败案例完全相同。

Also I will like to add that if I test sending the push notification when the device has not access to internet, and then I give access to the internet to the device it works fine too.

另外我想补充一点,如果我在设备无法访问互联网时测试发送推送通知,然后我可以访问设备的互联网,它也能正常工作。

I've tested for the provided sample in worklight tutorial and the same issue is happening, however in this case I'm not testing with the websphere server, I'm testing with the local worklight server, so I don't see the server logs do not apply to this case.

我已经在worklight教程中测试了提供的示例,同样的问题正在发生,但是在这种情况下,我没有使用websphere服务器进行测试,我正在使用本地worklight服务器进行测试,所以我没有看到服务器日志不适用于这种情况。

Has anybody faced this issue and found a solution?

有人遇到过这个问题并找到了解决方案吗?

Thank you very much in advance.

非常感谢你提前。

1 个解决方案

#1


Writing this as an Answer as the comment has character limit... This is not a complete answer to the question you are having

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

  • When the application is on the foreground the notification bar won't show the message as it will be consumed by the application. Otherwise the message goes to the notification bar.

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

  • When the device is powered off or it is not in the network, the message is delivered when the device connects to the network. Its delivered to the notification bar if the application is not in the foreground.

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

The term "application is powered off" as I understand means that the application is closed or it is not running even in the background... Right?

我理解的术语“应用程序已关闭”意味着应用程序已关闭或即使在后台运行也不会运行...对吗?

From the tests I did with the sample, I see that the notification does get delivered to the notification bar. Also I don't see the "FWLSE3002E: The resource is not found" with the push notification sample. To be able to help you better, can you please describe the steps you followed to hit this issue with the Push Notification sample.

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

#1


Writing this as an Answer as the comment has character limit... This is not a complete answer to the question you are having

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

  • When the application is on the foreground the notification bar won't show the message as it will be consumed by the application. Otherwise the message goes to the notification bar.

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

  • When the device is powered off or it is not in the network, the message is delivered when the device connects to the network. Its delivered to the notification bar if the application is not in the foreground.

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

The term "application is powered off" as I understand means that the application is closed or it is not running even in the background... Right?

我理解的术语“应用程序已关闭”意味着应用程序已关闭或即使在后台运行也不会运行...对吗?

From the tests I did with the sample, I see that the notification does get delivered to the notification bar. Also I don't see the "FWLSE3002E: The resource is not found" with the push notification sample. To be able to help you better, can you please describe the steps you followed to hit this issue with the Push Notification sample.

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