2015-07-20 56 views
0

我已經將教程推送通知應用程序與我的Android項目集成在一起。面對應用程序的兩個問題。使用IBM MobileFirst在模擬器上不推回的推送通知

問題1: 我的應用程序成功註冊了廣播推送通知。在調用適配器發送廣播通知的同時,當應用程序處於前臺時,它工作得很好。 當我按Home鍵,然後調用適配器廣播通知通知,通知不會在android模擬器上收到。它在logcat中顯示下面的錯誤。看起來像GCM推送通知,但沒有發送給客戶端。

07-20 06:40:21.748: V/GCMBroadcastReceiver(1899): onReceive: com.google.android.c2dm.intent.RECEIVE 
07-20 06:40:21.748: V/GCMBroadcastReceiver(1899): GCM IntentService class: com.FinacleMobileApp.GCMIntentService 
07-20 06:40:21.748: V/GCMBaseIntentService(1899): Acquiring wakelock 
07-20 06:40:21.789: V/GCMBaseIntentService(1899): Intent service name: GCMIntentService-DynamicSenderIds-2 
07-20 06:40:21.848: D/GCMIntentService(1899): GCMIntentService.onMessage in GCMIntentService.java:107 :: WLGCMIntentService: Received a message from the GCM server 
07-20 06:40:21.848: V/GCMBaseIntentService(1899): Releasing wakelock 
07-20 06:40:21.888: W/GCMIntentService(1899): GCMIntentService.onMessage in GCMIntentService.java:114 :: Unable to update badge while received push notification, becasue failed to parse badge number null, badge must be an integer number. 
07-20 06:40:21.918: D/GCMIntentService(1899): GCMIntentService.addToIntentQueue in GCMIntentService.java:147 :: WLGCMIntentService: App is on foreground but init is not comeplete. Queue the intent for later re-sending when app is back on foreground. 
07-20 06:40:21.748: V/GCMBroadcastReceiver(1899): onReceive: com.google.android.c2dm.intent.RECEIVE 
07-20 06:40:21.748: V/GCMBroadcastReceiver(1899): GCM IntentService class: com.FinacleMobileApp.GCMIntentService 
07-20 06:40:21.748: V/GCMBaseIntentService(1899): Acquiring wakelock 
07-20 06:40:21.789: V/GCMBaseIntentService(1899): Intent service name: GCMIntentService-DynamicSenderIds-2 
07-20 06:40:21.848: D/GCMIntentService(1899): GCMIntentService.onMessage in GCMIntentService.java:107 :: WLGCMIntentService: Received a message from the GCM server 
07-20 06:40:21.848: V/GCMBaseIntentService(1899): Releasing wakelock 
07-20 06:40:21.888: W/GCMIntentService(1899): GCMIntentService.onMessage in GCMIntentService.java:114 :: Unable to update badge while received push notification, becasue failed to parse badge number null, badge must be an integer number. 
07-20 06:40:21.918: D/GCMIntentService(1899): GCMIntentService.addToIntentQueue in GCMIntentService.java:147 :: WLGCMIntentService: **App is on foreground but init is not comeplete.Queue the intent for later re-sending when app is back on foreground. 

問題2: 在同一個應用程序我試圖註冊通知的標籤(供應)。我正在爲這個標籤調用訂閱方法。代碼如下所示。使用NotificationCenter.js。當我從我的appcontroller調用subscribeForTagNotification(higlighted below)函數。我得到Cant訂閱,通知令牌沒有在服務器上更新。

請讓我知道我是否缺少任何東西。 MF服務器連接調用啓動後立即調用SubscribeforTagNotification函數。我的應用程序使用WL.client.initconnectOnStartUp建立連接爲真。

AppController.factory('NotificationCenter', ['$http', '$rootScope', '$q', '$location', '$timeout', 
              function($http, $rootScope, $q, $location, $timeout) { 

    if (WL.Client.Push) { 
     WL.Logger.debug("Ganesh Notification center on ready to subscribe"); 
     //WL.Client.connect({onSuccess: connectSuccess, onFailure: connectFailure}); 
     WL.Logger.debug("Ganesh connection waiting complete"); 
     WL.Client.Push.onReadyToSubscribe = function() { 
     WL.SimpleDialog.show("Tag Notifications", "Ready to subscribe", [ { 
       text : 'Close', 
       handler : function() {} 
      } 
      ]); 

     }; 

    } 

    function doSubscribeSuccess() { 
     WL.Logger.debug("Ganesh doSubscribeSuccess"); 
     WL.SimpleDialog.show("Tag Notifications", "Subscribed to tag",[{ 
      text:'Close',handler :function(){} 
     }]); 
    } 

    function doSubscribeFailure() { 
     WL.Logger.debug("Ganesh doSubscribeFailure"); 
     WL.SimpleDialog.show("Tag Notifications", "Subscribed to tag",[{ 
      text:'Close',handler :function(){} 
     }]); 
    } 

    WL.Client.Push.onMessage = function (props, payload) { 
     WL.SimpleDialog.show("Tag Notifications", "Provider notification data: " + JSON.stringify(props), [ { 
      text : 'Close', 
      handler : function() { 
      WL.SimpleDialog.show("Tag Notifications", "Application notification data: " + JSON.stringify(payload), [ { 
       text : 'Close', 
       handler : function() {} 
       }]);  
      } 
     }]); 
    }; 

return { 

    init: function() { 

     }, 
    **subscribeForTagNotification:function()**{ 
        WL.Logger.debug("Ganesh doSubscribe feature"+WL.Client.Push.isTagSubscribed("OFFERS")); 
     if (WL.Client.Push && !WL.Client.Push.isTagSubscribed("OFFERS")) { 
       WL.Logger.debug("Ganesh doSubscribe feature entered"); 
       WL.Client.Push.subscribeTag("OFFERS", { 
        onSuccess: doSubscribeSuccess, 
        onFailure: doSubscribeFailure 
       }); 
      } 

     } 

    }; 

}]); 

IBM MobileFirst版本:6.3.0.00-20141127-1357 平臺:Android的

回答

0

對於要在模擬器工作推送通知,你需要有 Target : Google API否則它不會對你仿真器。

我希望你能得到我想說的目標是指你的虛擬設備的AVD (Anddroid虛擬設備目標)。

+0

蔭使用谷歌API 17我的應用程序。我能夠接收廣播通知,但僅面向特定場景提及所提及的問題。 –

+0

問題1)由於應用程序不在前臺,本地層正在接收通知並對其進行排隊。您是否在通知欄中看到通知? 問題2)您是否在「onReadyToSubscribe」之前嘗試訂閱?是否有計時問題? –

0

如果您的組織有限制流量或從互聯網上防火牆,則必須經過以下幾個步驟:

Configure the firewall to allow connectivity with GCM so that your GCM client apps can receive messages. The ports to open are 5228, 5229, and 5230. GCM typically uses only 5228, but it sometimes uses 5229 and 5230. GCM does not provide specific IP, so you must allow your firewall to accept outgoing connections to all IP addresses that are contained in the IP blocks listed in Google ASN of 15169. For more information, see Implementing an HTTP Connection Server. 

Ensure that your firewall accepts outgoing connections from MobileFirst Server to android.googleapis.com on port 443.