我已将教程推送通知应用程序与我的Android项目集成。面对应用程序的两个问题。
问题1: 我的应用程序成功注册广播推送通知。在调用适配器发送广播通知时,当应用程序在前台时,它可以正常工作。 当我按主页键然后调用适配器进行广播通知通知时,在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: 在同一个应用程序中,我试图注册一个标签(OFFERS)进行通知。我正在为此标记调用subscribe方法。代码如下。使用NotificationCenter.js。当我从我的appcontroller调用subscribeForTagNotification(下面突出显示)函数时。我得到 Cant订阅,服务器上没有更新通知令牌。
如果我错过了什么,请告诉我。在启动MF服务器连接调用后立即调用SubscribeforTagNotification函数。我的应用使用 WL.client.init 与 connectOnStartUp 建立连接为真。
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 平台:机器人
答案 0 :(得分:0)
要使推送通知能够在模拟器上运行,您需要拥有
Target : Google API
否则它不适用于你的模拟器。
我希望你能得到我想说的目标指的是AVD (Anddroid Virtual Device Target)用于创建的虚拟设备。