Pushwoosh / pushwoosh-react-native-plugin

Other
57 stars 43 forks source link

Pushwoosh.unregister() changes device token #141

Closed rarenatoe closed 1 year ago

rarenatoe commented 2 years ago

I am using Pushwoosh and a second service to see which one performs best. I have split flags setup to dictate which service to use for each user account. My code consists of an interface that calls the unregister function of the service not being used. So when the second service is used, Pushwoosh is meant to be turned off. Otherwise both services send push notifications.

The issue comes when Pushwoosh.unregister() is called. Instead of removing the device token from the Pushwoosh database, it changes the device token. Not sure why it does it nor if it was meant to be a long term solution, but it effectively messes up with all other services, because the token they use is the one provided to them at app instalation time, not the newly generated one (~1 second later) at unregister() call time, and NativeModules.RNPushNotification.getToken() doesn't trigger for this second time.

Edit: As a workaround I am using Pushwoosh.setUserId('XXXXXX') to intentionally set an invalid user and thus not receive push notifications for this user. Is this workaround the best available? Is there anything else I can do?

wfhm commented 2 years ago

@rarenatoe

This is the default behavior of our SDK by now. I'll discuss with the team whether we should change it to just removing a token from our database, as in your particular use-case it obviously causes issues.

Meanwhile, to properly route push notifications received from multiple push providers and manage push tokens after they are updated we recommend creating a main FirebaseMessagingService in your Android project. Please refer to the guide below:

https://docs.pushwoosh.com/platform-docs/pushwoosh-sdk/android-push-notifications/customizing-android-sdk/android-faq#using-pushwoosh-sdk-with-other-fcm-services

rarenatoe commented 1 year ago

Understood, thank you.