3

我正在IBM Worklight 6.3上開發應用程序,並且應用程序使用推送通知。該應用程序使用IBM Websphere應用程序服務器8.5.5.0。以下是我們必須進行推送通知的詳細信息。Worklight 6.3通過GCM推送通知未達到android設備

  1. 對於android的代碼,已添加谷歌服務器密鑰作爲API密鑰和項目號作爲發件人ID。我也嘗試使用谷歌瀏覽器的關鍵,因爲很少有早期的帖子已經提出,儘管IBM聲明要使用服務器密鑰。
  2. 對於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類已宣佈延長

    package com.POCMobileApp; 
    public class GCMIntentService extends com.worklight.androidgap.push.GCMIntentService { 
    
    }</code> 
    
  4. 的適配器程序被定義可以提交通知

    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. 客戶端側面實現功能WL.Client.Push.onMessage

我調用適配器程序作爲

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

和下面

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

回報沒有錯誤,同時調用程序,但有在訂閱的設備上沒有收到通知。從設備的logcat痕跡中,我瞭解設備已經與GCM服務器建立了連接,並且註冊成功。以下是在跡線:

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 - taYs9I9WCEZMwUFT z837eJXTfF3I8NMFr7jDBIYlgUrgXreoUUAYej62VmFZZoRofLBSOc6f9rKnkvXsOR3GafwsrZnIjNWp, 誤差= NULL,未註冊= NULL 12-10 21:40:09.161: d/GCMRegistrar(18771):用於com.POCMobileApp 12-10復位退避 21:40:09.161:V/GCMRegistrar(18771):上應用版本保存REGID 1 12-10 21:40:09.166:d/GCMIntentService(18771): GCMIntentService.onRegistered在GCMIntentService.java:81 :: WLGCMIntentService:在與登記ID APA91bH-QI_73vpf5sqvuvdkqha9QFNzvKa5FZGhGh的GCM服務器中註冊 -

請問你能告訴我哪裏出錯了嗎?另外,我不清楚如何調用WL.Server.sendMessage(它在適配器級別)將建立與GCM服務器的連接,有人可以澄清?

EDIT

我注意到,每一個適配器被調用下面的錯誤時間出現在SystemErr.log

[15年12月14日12:33:44:452 EST] 00000074 SystemErr R java.util.MissingResourceException:找不到綁定的資源 java.util.PropertyResourceBundle,密鑰無法搭載 configprofile由於客戶端發送的標頭無效或不完整 [12/14/15 12:33: 44:452 EST] 00000074 SystemErr R java.util.ResourceBundle.getObject(ResourceBundle.java:404)[12/14/15 12:33:44:452 EST] 00000074 SystemErr R 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.gadget s.serving.ClientConfigProfileServlet.piggybackConfigProfile(ClientConfigProfileServlet.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在 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 com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager。java:928) [12/14/15 12:33:44:452 EST] 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.HttpInboundLink.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蛋白(Htt pInboundLink.java:283) [15年12月14日12:33:44:452 EST] 00000074 SystemErrř在 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在 com.ibm.ws.ssl.channel.impl.SSLReadServiceContext $ SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784) [12/14/15 12:33: 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 a t 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 。一世o.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)

它可以是相關的嗎?有沒有可能消息沒有形成並傳輸給GCM?

謝謝。

+0

您好,我想現在您可以通過Google開發者控制檯「API請求圖表」查看您呼叫是否已達到GCM的天氣。如果它發送到GCM服務器,那麼推送通知根本沒有達到GCM,所以問題出在你的worklight服務器端。 –

+0

請參閱此帖以獲取更多詳細信息http://stackoverflow.com/questions/29808360/push-notification-doesnt-work-in-a-liberty-profile –

+0

問題: 1)您是否以任何方式修改了GCMIntentService類?你有沒有重寫方法? 2)更新帖子以包含您的客戶端推送處理邏輯。 –

回答

0

用戶不會發表評論中的答案...這裏是:

廣播通知功能現在正在工作。我們已做出以下更改以使其正常工作 - 1.打開網絡端口。 2.僅刪除了Android項目的安全測試。此外,應用程序服務器重新啓動是任何改變都必須反映。