Is ionic framework has any predefined rule to implement GCM for android

Implementing GCM for push notification in android device …is there any other thing needs to understand for hybrid app with Ionic.

or how we will display received notification in our app.

Depending on where you look, you’ll find a bunch of resources. It’s really an issue with getting things to play well angular and not throw any errors. But our cordova wrappers help with that.

3 Likes

hi mhartington.i am using same code but after calling register method getting OK response but where i will get registration id from GCM.could you please provide me complete flow of this.

 var androidConfig = {
            "senderID": "**********",
            "ecb": "onNotification"
        };
        $cordovaPush.register(androidConfig).then(function (result) {
            // Success!         
        }, function (err) {
            // An error occured. Show a message to the user
        });
1 Like

Are you asking where exactly do you get the GCM registration ID?

For that, you should check out the GCM docs.

http://developer.android.com/google/gcm/gcm.html

Or do you mean, where do you add that to the js?

I have the same as sandy.
$cordovaPush.register return result = OK.
Then, How can I get Registration Id

Hi @mhartington,

I implemented GCM. I am getting reg-Id and save on server.

I want to receive notification when add , update and delete operation happen on server (GCM notification send code written in PHP.).
But, How can i get notification on device??? How can i create notification receiver method ??

you need to add service for getting reg-id.
For that, you should check out the angularjs cordova push notification docs.
https://www.scorchsoft.com/blog/free-angularjs-cordova-push-notification-plugin/

You can also use this -
http://intown.biz/2014/04/11/android-notifications/

Let me know if there is any issue while getting registration id.

It’s work. Thank you

Are you getting notification ?

yes, I got reg Id which I use for server push message to it.
But now I get problem about receive message notification when android phone screen off, It seem app not run as background service for listening push message.
Could someone tell me how deal with that?

I did not implemented receiving notification.
Can you post the code of receive message notification ??

I implement by following this tut
http://intown.biz/2014/04/11/android-notifications/

I also using same. But i am get getting notification.
I want to send notification to device when add , update and delete operation happen on serve. Can you tell me the step ?

Have you test on the real phone? and what error log show on chrome dev?

I tested on device before some time. it is working now… :slight_smile:

Could you make phone receive push notification after a few minutes screen off?

I didn’t implemented yet…

If application is in foreground then it is not displaying push notification.
How can display notification??
Did you implemented ??

you should check is onNotificationGCM function called when receive notification

Foreground case only Alert is displaying … how to display the notification ??