I have integrated tutorial push notification application with my Android Project. Facing two issues with the app.
Issue 1: My app registers for broadcast push notification sucessfully. And while invoking adapter to send broadcast notification, when application is in foreground it works perfectly fine. When i press home key and then invoke adapter for broadcast notification notification, notification is not recieved on android emulator. It shows below error in logcat. Seems like GCM has pushed notification but its not sent to client.
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.
Issue 2: In same application i am trying to register a Tag(OFFERS) for notification. I am invoking subscribe method for this tag. Code is as follows.NotificationCenter.js is used. when i invoke subscribeForTagNotification (higlighted below) function from my appcontroller. I get Cant Subscribe, notification token is not updated on the server.
Kindly let me know if i am missing anything. SubscribeforTagNotification function is called immediately after MF server connection call is initiated. My app used WL.client.init to make a connection with connectOnStartUp as true.
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 version: 6.3.0.00-20141127-1357 Platform:Android