我正在开发一个可与推送通知一起使用的Worklight应用程序。我目前正在Android上进行测试,并且已经有适配器向应用发送推送通知。问题是:应用程序只在前台接收它。如果它位于背景上,它不会收到它,并且在通知区域中显示一条消息后将其打开。当我点击通知区域内的消息时,该应用程序也不会打开。点击通知区域中的邮件时,应用程序未打开
我学习了PushNotifications示例,它看起来像我做的一样。我在Android清单文件中对照例子中的权限等进行了交叉检查。但是,它似乎并不奏效。下面是运行PushNotifications示例时日志的摘录。
10-08 09:58:48.227: V/GCMBroadcastReceiver(2771): onReceive: com.google.android.c2dm.intent.RECEIVE
10-08 09:58:48.227: V/GCMBroadcastReceiver(2771): GCM IntentService class: com.PushNotifications.GCMIntentService
10-08 09:58:48.227: V/GCMBaseIntentService(2771): Acquiring wakelock
10-08 09:58:48.237: V/GCMBaseIntentService(2771): Intent service name: GCMIntentService-DynamicSenderIds-4
10-08 09:58:48.237: D/GCMIntentService(2771): GCMIntentService.onMessage in GCMIntentService.java:101 :: WLGCMIntentService: Received a message from the GCM server
10-08 09:58:48.237: W/GCMIntentService(2771): 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.
10-08 09:58:48.257: V/GCMBaseIntentService(2771): Releasing wakelock
10-08 09:58:48.257: D/GCMIntentService(2771): 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.
10-08 09:58:48.277: D/push(2771): Push$1.onReceive in Push.java:91 :: Push: Queuing message for dispatch to javascript
10-08 09:58:48.277: D/GCMIntentService(2771): GCMIntentService.onUnhandled in GCMIntentService.java:164 :: WLGCMIntentService: Showing notification for unhandled Message(alert=Hoi-hoi, badge=1, sound=null, payload={"alias":"myPush","custom":"data"})
10-08 09:59:20.837: D/Whitelist(2771): Unlimited access to network resources
10-08 09:59:20.837: I/CordovaLog(2771): Changing log level to DEBUG(3)
10-08 09:59:20.837: D/CordovaActivity(2771): Resuming the App
10-08 09:59:20.837: D/CordovaActivity(2771): CB-3064: The errorUrl is null
10-08 09:59:20.877: W/EGL_emulation(2771): eglSurfaceAttrib not implemented
10-08 09:59:20.907: D/dalvikvm(2771): GC_FOR_ALLOC freed 810K, 27% free 4785K/6516K, paused 25ms, total 25ms
10-08 09:59:20.917: D/push(2771): Push.dispatchPending in Push.java:390 :: Dispatching to javascript Message(alert=Hoi-hoi, badge=1, sound=null, payload={"alias":"myPush","custom":"data"})
10-08 09:59:20.917: D/WLClient(2771): WLClient$ActivityListener.onActivityStarted in WLClient.java:1180 :: on activity started com.PushNotifications.PushNotifications
10-08 09:59:20.917: D/WLClient(2771): WLClient$ActivityListener.onActivityResumed in WLClient.java:1169 :: on activity resumed com.PushNotifications.PushNotifications . activity count = 1
我的一个几乎是相同的,除了从下面的第三行(D /推(2771):Push.dispatchPending)丢失。它似乎从未将排队的事件分发给应用程序。
我可能会错过什么?
Worklight版本是6.2.0.00-20140922-2259。
在Studio中创建应用程序后,您是否已将res \ values \ strings.xml中的应用程序重命名? – 2014-10-08 14:32:01
此外,始终提及您的Worklight Studio版本和内部版本号。 – 2014-10-08 14:32:18
我已更新版本号的问题。 你的意思是在strings.xml中的app_name?我没有改变它。它从应用程序描述符中显示的名称中复制(我想)。但是,它与应用程序ID不同。如果您的意思是wlAppIdTitle,则默认值为“App ID”(就像推送示例应用程序一样)。 – 2014-10-08 15:07:03