问题
in my Application I'am currently sending a registration intent to the google server everytime the app starts. I get a different registration ID everytime I do that, though the old ones still work. I guess thats not a good way to do it. So I thought that I should send the registration intent only once - at the first start of the app. Now my question, if google refreshes the registration ID, do they inform the application about that? Whithout my app sending anything to them?
回答1:
I have an C2DM and my solution was to register on every start of the application, but when using when sending the C2DM messages through my server delete the entry of the database if the error code was a InvalidRegistration
So if a device was registered multiple times, I only send one invalid message.
回答2:
You could ping the business server if the registration have changed. You could ask for a registration update once a day.
Meaning that you can save the registration in the phone using the preferences and then only stream to the server if it has changed.
Although I am pretty sure the registration changes every time you ask for a new one. Maybe there's a way to check if a registration is still valid?
来源:https://stackoverflow.com/questions/8178855/android-c2dm-what-happens-if-registration-id-gets-refreshed