Regarding the handling of registrationId when changing Android devices

Asked 2 years ago, Updated 2 years ago, 89 views

I have created an Android app using GCM, and I have obtained the registrationId using the code below to send the push notification, and I have saved it in SharedPreferences.

registrationId=gcm.register("xxxx";

If you transfer data from an app using a backup tool, such as during a model change, the registrationId stored in SharedPreferences will also be transferred.

However, registrationId (which was obtained before the model change) does not send push notifications to new terminals.

What should I do in these cases?

Android M may use the "full-backup-content" and "exclude" tags to exclude specific data from data transfer, but since targetSDKversion 23 or higher is the target, what would be the best way to deal with this earlier version?

android java gcm

2022-09-30 21:14

1 Answers

Perhaps the situation has changed since the beginning of the question, but I will quote it from https://firebase.google.com/docs/cloud-messaging/android/legacy-regid?hl=ja.

Update Client Application: Existing Registration ID
when updating client applications The ID must be disabled because is not guaranteed to work with the new version.Recommended method is registration ID
Store the current version of the app when saving the
client
Compare this saved value with the current app version when the app is started.If the two do not match, disable the saved data and start the registration process again.

Backup and Restore: Do not save registration IDs when backing up client apps.The registration ID is the client. If the registration ID is invalid, it is not always valid until the application is restored. The application will also be in an invalid state (i.e., the application recognizes that it is registered, but the GCM recognizes that it is registered ID
). will no longer be saved, so the app will no longer retrieve messages.)We recommend that you start the registration process like when the app is installed for the first time.

Therefore, the registrationId obtained before the model change may be invalid, so let's get and register the registrationId again after the model change.


2022-09-30 21:14

If you have any answers or tips

Popular Tags
python x 4647
android x 1593
java x 1494
javascript x 1427
c x 927
c++ x 878
ruby-on-rails x 696
php x 692
python3 x 685
html x 656

© 2024 OneMinuteCode. All rights reserved.