I've put together a skeleton client/server GCM app that accepts and displays messages on my Android phone from my rough and ready server. I say 'skeleton 'and 'rough and ready' because my app's registration_id is hard coded into the server side as the value I captured in the debugger when I started the sample Android app and registered the app/device combination on the GCM server. I was about to start working on providing a read/write mechanism for the two sides to access a simple database on the server to store the reg_id/device combinations when I got to thinking:
I know this reg_id can expire at any time, because Google say it can. It's clear from the docs how to check that the id is still OK IF, and it's a big IF, I start the app again. However, why should I, or any other user, start it again? The GCMIntentService, registered in the manifest is sitting there picking up messages as required and there's no need to run the app again for any reason. So when the id expires, I'll stop getting messages - the server might know from the return code, but won't be able to inform my app - no recovery unless I run the app again and go through its onCreate()
and presumably registerClient()
methods.
So what happens when the id expires? I don't see that any of the on.. methods in the IntentService will execute. Will Google themselves send a normal message saying it's about to expire? Do I need to write an alarm task to run daily and check the id?