2015-07-20 80 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.