我正在開發一個可與推送通知一起使用的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