I am new to GCM, I was curious to know how GCM works when application is inactive in Android. How to handle receiving messages when app is closed or opened. what is the best way to store notifications
Here is a link to the GCM tutorial: https://developers.google.com/cloud-messaging/
Basically how it will work is you will need to setup a listener class in your project that will listen for anything coming in. You can listen to callbacks onReceived, onOpened, etc. Then you can intent out to whatever you want on the click of that notification.
The way it will work for app closed or opened will need to be decided by the developer. If you don't distinguish, then all notifications will appear in the notification menu. You will also need to unregister from the service once you logout or whenever you don't want the pushes anymore.
Here is a step by step tutorial on this: https://www.pubnub.com/blog/2015-06-24-sending-receiving-android-push-notifications-with-gcm-google-cloud-messaging/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With