Reputation: 3
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
Upvotes: 0
Views: 342
Reputation: 73
If your organization has a firewall that restricts the traffic to or from the Internet, you must go through the following steps:
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.
Upvotes: 0
Reputation: 3220
For Push notification to be working on Emulator you need to have
Target : Google API
else it wont work on you Emulator.
i hope you get what i am trying to say target refers to the AVD (Anddroid Virtual Device Target) for your created Virtual device.
Upvotes: 0