Why Am I Unable To Receive Push Notification On Android By Ionic Framework
I had written this small test app to test the New ionic push and in the backend I am using Android Google Cloud Messaging Service. I am getting success from the android GCM in my f
Solution 1:
can you confirm that the http request to send token to server is executed? if i'm not mistaken, android tokens are received in a push notification to the phone via gcm in your onRegister callback as:
app.run(function($ionicPlatform, $ionicPush,$http) {
$ionicPlatform.ready(function() {
$ionicPush.init({
"onNotification": function(notification) {
var payload = notification.payload;
console.log(payload);
console.log(notification);
},
"onRegister": function(data) {
console.log(data.token);
//works for androidvar reg = { regId: data.token };
$http.post('http://app.example.com/sendPushNot', reg)
.then(function(response){
console.log(response);
}, function (error){
console.log(error);
});
}
});
$ionicPush.register(function(data){
//works for ios var reg = {
regId : data.token
};
$http.post('http://app.example.com/sendPushNot', reg)
.then(function(response){
console.log(response);
}, function (error){
console.log(error);
});
});
Solution 2:
Okay, guys here it goes, after my final showdown I was the winner. I figured out finally. I had not entered the app_id
field. It was something related completely to ionic so it wouldn't be true for android people. It was a small issue. Had I looked at the source code earlier. I would have known it by now. But anyways four days to solve and finally it's working.
If anythings is not working post in the comments I'll help you out.
So the flow goes like this.
ionic config set dev_push false
ionic push --google-api-key AIzaSyB9L****************5if1m5k5JOVMw
ionic config set gcm_key 148*****5078ionic config setapp_id (some_alphanumeric_value found on ionic.io andis availble after you have done ionic io init)
Post a Comment for "Why Am I Unable To Receive Push Notification On Android By Ionic Framework"