pusher / push-notifications-android

Android SDK for Pusher Beams
https://www.pusher.com/beams
MIT License
21 stars 21 forks source link

How to unregister from an instance_id #114

Closed NourhanGehad closed 3 years ago

NourhanGehad commented 3 years ago

We have changed the instance, and after uploading the new version of the mobile app, it crashes on the user's phone and we recognized that the users are getting this crash due to trying to register to the new instance id and it requires them to uninstall and reinstall the app.

We deleted the old instance from our pusher account and we thought this is going to unregister the devices from the old instance, but unfortunately we still get the same error.

How to unregister a device (from an instance_id) when the user updates the app or how to solve this issue.??

benw-pusher commented 3 years ago

Hi! I believe you have contacted our support team about this issue who have provided some code that can be used for this. I will close this issue as this is not a bug with the library.

NourhanGehad commented 3 years ago

Yes, someone already answered the email and the following worked for me. I'll leave it here for others who may need it later

I believe you will need to issue an update to your app that includes the code below immediately before you try and register/start the PushNotifications service with the new instance ID.

DeviceStateStore deviceStateStore = new DeviceStateStore(applicationContext); if (deviceStateStore.getInstanceId().equals("OLD_INSTANCE_ID")) { Log.e("TESTING", "clearing state"); deviceStateStore.clear(); } // Start beams SDK with new Instance ID