Android GCM registration ID change

2019-09-01 02:53发布

问题:

I know this is a silly question but important for me. I am developing an application which uses GCM. I searched and read regarding the GCM and having some question related to this as:

  1. Is the registration_id of GCM change after App update? If yes then how to handle it?
  2. Is the registration_id of GCM change after Android update? If yes then how to handle it?
  3. Is the registration id changes with every time registration to GCM from the same device and same app?
  4. Do the app need to call registration to GCM method every time when app runs?
  5. Can the app wait till the token or registration process complete in background?

I refereed the This Link to implement GCM in my app.

回答1:

check GCM

The periodical refresh never happened. The registration refresh is not included in the new GCM library.

However you can also unregister device and set expiry on it.

Do the app need to call registration to GCM method every time when app run?

No until you unregister you dont need to call it.



回答2:

I'll try to answer some of your questions.

  1. Is the registration_id of GCM change after App update? If yes then how to handle it?

Ans. : Yes, registration_id of GCM change after App update here you can find explanation.

  1. Is the registration_id of GCM change after Android update update? If yes then how to handle it?

Ans. : Yes, registration_id of GCM change after App update here you can find explanation.

  1. Is the registration id changes with every time registration to GCM from the same device and same app?

Ans. : No, It'll be same as long as the app is not updated or android version of device is not changed.

  1. Do the app need to call registration to GCM method every time when app run?

Ans. : If you have an app where user has to do login then at login success step you can but registration. And it doesn't take much time to register the device. If the id is changed, it'll give new id or else will return old one so no worries about duplication or such problems.

  1. Can the app wait till the token or registration process complete in background?

Ans. : You can do this in background thread as well. But it doesn't take much time so you can do it normally as well.

I hope, am able to answer you questions. Let me know if I am wrong anywhere. Accept my answer if you agree with me.

Thanks.