简体   繁体   English

通过GCM的Worklight 6.3推送通知无法到达Android设备

[英]Worklight 6.3 push notification via GCM does not reach android device

I am developing an application on IBM Worklight 6.3 and application uses push notification. 我正在IBM Worklight 6.3上开发一个应用程序,应用程序使用推送通知。 The application uses IBM Websphere application server 8.5.5.0. 该应用程序使用IBM Websphere应用程序服务器8.5.5.0。 Below are the details which we have to make push notification work. 以下是我们必须进行推送通知工作的详细信息。

  1. For android code, have added google server key as API key and project number as sender id. 对于Android代码,已添加谷歌服务器密钥作为API密钥和项目编号作为发件人ID。 I have also tried with google browser key as few earlier posts have suggested though IBM states server key to be used. 虽然IBM声明要使用服务器密钥,但我还尝试使用谷歌浏览器密钥,因为之前的帖子很少。
  2. For android manifest, 对于Android清单,

     <uses-permission android:name="android.permission.GET_ACCOUNTS"/> <uses-permission android:name="android.permission.WAKE_LOCK"/> <permission android:name="com.POCMobileApp.permission.C2D_MESSAGE" android:protectionLevel="signature"/> <uses-permission android:name="com.POCMobileApp.permission.C2D_MESSAGE"/> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/> <service android:name="com.POCMobileApp.GCMIntentService"/> <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND"> <!-- Receive the actual message --> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE"/> <category android:name="com.POCMobileApp"/> </intent-filter> <!-- Receive the registration id --> <intent-filter> <action android:name="com.google.android.c2dm.intent.REGISTRATION"/> <category android:name="com.POCMobileApp"/> </intent-filter> </receiver> 
  3. GCMIntentService class has been declared to extend GCMIntentService类已声明为扩展

     package com.POCMobileApp; public class GCMIntentService extends com.worklight.androidgap.push.GCMIntentService { }</code> 
  4. An adapter procedure is defined which can submit the notification 定义了可以提交通知的适配器过程

     function sendBroadcastNotification(notificationText) { WL.Logger.info("Notification text -> " + notificationText); var notificationOptions = {}; notificationOptions.message = {}; notificationOptions.message.alert = notificationText; notificationOptions.settings = {}; notificationOptions.settings.gcm = {}; notificationOptions.settings.gcm.payload = {"custom":"data"}; try { var timeOut = WL.Server.sendMessage("POCMobileApp", notificationOptions); } catch(e) { WL.Logger.info("Error encountered -> " + e); } return { result : "Notification sent to all users." }; } 
  5. Client side implementation of functions WL.Client.Push.onMessage 客户端实现WL.Client.Push.onMessage函数

I am invoking the adapter procedure as 我正在调用适配器过程

https://myServername:9443/myApplication/invoke?adapter=PushNotificationAdapter&procedure=sendBroadcastNotification&parameters=%5B"test+notification"%5D

and that returns below 并返回以下

/*-secure-
{"result":"Notification sent to all users.","isSuccessful":true}*/

There is no error while invoking the procedure but there is no notification received on the subscribed devices. 调用过程时没有错误,但订阅的设备上没有收到通知。 From logcat traces of devices, i understand that device has established a connection with GCM server and registration is successful. 从设备的logcat跟踪中,我了解设备已与GCM服务器建立连接并且注册成功。 Below are the traces : 以下是痕迹:

12-10 21:40:09.151: V/GCMBroadcastReceiver(18771): onReceive: com.google.android.c2dm.intent.REGISTRATION 12-10 21:40:09.151: V/GCMBroadcastReceiver(18771): GCM IntentService class: com.POCMobileApp.GCMIntentService 12-10 21:40:09.151: V/GCMBaseIntentService(18771): Acquiring wakelock 12-10 21:40:09.156: V/GCMBaseIntentService(18771): Intent service name: GCMIntentService-DynamicSenderIds-2 12-10 21:40:09.161: D/GCMBaseIntentService(18771): handleRegistration: registrationId = APA91bH-QI_73vpf5sqvuvdkqha9QFNzvKa5FZGhGh--taYs9I9WCEZMwUFTz837eJXTfF3I8NMFr7jDBIYlgUrgXreoUUAYej62VmFZZoRofLBSOc6f9rKnkvXsOR3GafwsrZnIjNWp, error = null, unregistered = null 12-10 21:40:09.161: D/GCMRegistrar(18771): resetting backoff for com.POCMobileApp 12-10 21:40:09.161: V/GCMRegistrar(18771): Saving regId on app version 1 12-10 21:40:09.166: D/GCMIntentService(18771): GCMIntentService.onRegistered in GCMIntentService.java:81 :: WLGCMIntentService: Registered at the GCM server with registration id APA91bH-Q 12-10 21:40:09.151:V / GCMBroadcastReceiver(18771):onReceive:com.google.android.c2dm.intent.REGISTRATION 12-10 21:40:09.151:V / GCMBroadcastReceiver(18771):GCM IntentService类:com .POCMobileApp.GCMIntentService 12-10 21:40:09.151:V / GCMBaseIntentService(18771):获取唤醒锁12-10 21:40:09.156:V / GCMBaseIntentService(18771):意图服务名称:GCMIntentService-DynamicSenderIds-2 12-10 21:40:09.161:d / GCMBaseIntentService(18771):handleRegistration:registrationId = APA91bH-QI_73vpf5sqvuvdkqha9QFNzvKa5FZGhGh - taYs9I9WCEZMwUFTz837eJXTfF3I8NMFr7jDBIYlgUrgXreoUUAYej62VmFZZoRofLBSOc6f9rKnkvXsOR3GafwsrZnIjNWp,误差= NULL,未注册= NULL 12-10 21:40:09.161:d / GCMRegistrar(18771):用于重置回退com.POCMobileApp 12-10 21:40:09.161:V / GCMRegistrar(18771):在应用版本1上保存regId 12-10 21:40:09.166:D / GCMIntentService(18771):GCMIntentService.onRegistered in GCMIntentService.java:81 :: WLGCMIntentService:在注册ID为APA91bH-Q的GCM服务器上注册 I_73vpf5sqvuvdkqha9QFNzvKa5FZGhGh-- I_73vpf5sqvuvdkqha9QFNzvKa5FZGhGh--

Can you please suggest where am i going wrong ? 你能告诉我哪里出错吗? Also which is not clear to me how calling WL.Server.sendMessage (which is at adapter level) will establish connection with GCM server, can someone clarify ? 另外我不清楚如何调用WL.Server.sendMessage(在适配器级别)将与GCM服务器建立连接,有人可以澄清吗?

EDIT 编辑

I have noticed that every time the adapter is invoked the below error appears in SystemErr.log 我注意到每次调用适配器时,SystemErr.log中都会出现以下错误

[12/14/15 12:33:44:452 EST] 00000074 SystemErr R java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key could not piggyback configprofile due to invalid or incomplete headers sent from client [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at java.util.ResourceBundle.getObject(ResourceBundle.java:404) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at java.util.ResourceBundle.getString(ResourceBundle.java:364) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.common.i18n.MessageFormatter.format(MessageFormatter.java:111) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.common.i18n.MessageFormatter.format(MessageFormatter.java:89) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.common.log.WorklightServerLogger.warn(WorklightServerLogger.java:64) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.gadgets.serving.ClientConfigProfileServlet.piggybackConfigProfile(ClientConf [12/14/15 12:33:44:452 EST] 00000074 SystemErr R java.util.MissingResourceException:无法找到bundle java.util.PropertyResourceBundle的资源,由于发送的无效或不完整的标头,key无法搭载configprofile客户端[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at java.util.ResourceBundle.getObject(ResourceBundle.java:404)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at java.util.ResourceBundle.getString(ResourceBundle.java:364)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.common.i18n.MessageFormatter.format(MessageFormatter。 java:111)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.common.i18n.MessageFormatter.format(MessageFormatter.java:89)[12/14/15 12:33 :44:452 EST] 00000074 SystemErr R at com.worklight.common.log.WorklightServerLogger.warn(WorklightServerLogger.java:64)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight .gadgets.serving.ClientConfigProfileServlet.piggybackConfigProfile(ClientConf igProfileServlet.java:238) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.gadgets.serving.InvokeProcServlet.service(InvokeProcServlet.java:82) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1227) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) [12/14/15 12:33:44:452 EST] igProfileServlet.java:238)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.gadgets.serving.InvokeProcServlet.service(InvokeProcServlet.java:82)[12/14/15 12 :33:44:452 EST] 00000074 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm .ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1227)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest( ServletWrapper.java:776)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458)[12/14 / 15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.core.auth.impl.AuthenticationFilter$1.execute(AuthenticationFilter.java:217) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:76) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:222) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928) [12/14/15 12:33:44:452 E 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.core.auth .impl.AuthenticationFilter $ 1.execute(AuthenticationFilter.java:217)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java :76)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:222)[12/14/15 12: 33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterManager .doFilter(WebAppFilterManager.java:928)[12/14/15 12:33:44:452 E ST] 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3761) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:976) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.http.channel.inbound.impl.Htt ST] 00000074 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws .webcontainer.webapp.WebApp.handleRequest(WebApp.java:3761)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup。 java:304)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:976)[12/14/15 12:33 :44:452 EST] 00000074 SystemErr R at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm .ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.http.channel.inbound.impl。 HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.http.channel.inbound.impl.Htt pInboundLink.handleNewRequest(HttpInboundLink.java:526) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283) [12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1048) [12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:642) [12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784) [12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175) [12/14/15 12:33:44:453 EST] pInboundLink.handleNewRequest(HttpInboundLink.java:526)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java) :312)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283)[12/14 / 15 12:33:44:452 EST] 00000074 SystemErr R at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1048)[12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.ws.ssl.channel.impl.SSLConnectionLink $ MyReadCompletedCallback.complete(SSLConnectionLink.java:642)[12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com .ibm.ws.ssl.channel.impl.SSLReadServiceContext $ SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)[12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.ws.tcp。 channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)[12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) [12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) [12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) [12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) [12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) [12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) [12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862) 00000074 SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)[12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.io.async.AsyncChannelFuture .fireCompletionActions(AsyncChannelFuture.java:161)[12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)[12/14 / 15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)[12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)[12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.io.async.ResultHandler $ 2。 run(ResultHandler.java:905)[12/14/15 12:33:44:453 EST] 00000074 SystemErr R at com.ibm.ws.util.ThreadPool $ Worker.run(ThreadPool.java:1862)

Can it be related ? 可以相关吗? Is there a possibility that message is not getting formed and transmitted to GCM ? 是否有可能消息未形成并传输到GCM?

Thanks. 谢谢。

The user will not post the answer from the comments... here it is: 用户不会发表评论中的答案......这里是:

Broadcast notification functionality is now working. 广播通知功能现在正在运行。 We have made below changes to make it work - 1. Opened network ports. 我们进行了以下更改以使其工作 - 1.打开网络端口。 2. Removed security test only for the android project. 2.仅删除了android项目的安全性测试。 Also app server restart was a must for any change to reflect. 此外,还需要重新启动应用服务器才能进行任何更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM