How is deleteInstance is supposed to work
kevinswartz opened this issue · comments
Hi Guys,
Thanks for your help with this plugin. I'm not sure if this is a bug report, or if I just don't understand how it's supposed to work.
I'm able to register for and receive push notifications on both ios/android. When our users log out, I need to unsubscribe from push notificaitons in case a different user were to log back in. To do that, I'm attempting to call deleteInstance() so that I can get a new token later. I can verify that deleteInstance() is being called, however I continue to receive push notifications for this token.
Does it not work the way I think it does? How can I stop receiving push notifications for a token?
Describe the bug
deleteInstance() is not unsubscribing from notifications for a token
To Reproduce
I register and get a push token via:
PushNotifications.register()
.then((res) => {
logger.log('push register result', res);
return FCM.getToken();
})
I unregister like this:
FCM.deleteInstance();
Expected behavior
I would expect no push notifications to be received once deleteInstance() has been called.
This happens on both ios/android:
ios v16.0.3
android 12
Plugin versions:
@capacitor/push-notifications v4.1.1
@capacitor-community/fcm v3.0.0
@ionic/react v6.1.14
react v17.0.2
Hi guys, any insight into this call? The docs say remove local fcm instance completely
, and I'm just looking for clarification on that. Is it supposed to reset your notification token or stop receiving notifications?
I believe it should do both. I really can't replicate this use case since I don't have anything running based on tokens. would you be able to put together a minimal reproduction demo?
Sure I can try working up a reproducible demo, though I think my issue pretty basic right now. If I register with notifications as I mentioned above, then call FCM.deleteInstance()
about 30 seconds later, I keep getting notifications for that token, even hours later. I'll see if I can get a demo together. Thanks!
https://github.com/thuongnv-lib/fcm
This fork contains this feature and deletion of the token works there.
Hi Guys! So it's been a while, but I'm still seeing this issue. I've updated everything to the latest, but I still receive push notifications up to an hour after calling deleteInstance()
. This happens on both android and ios. Here's my current versions:
@capacitor/ios: 5.6.0
@capacitor/android: 5.6.0
@capacitor/core: 5.6.0
@capacitor-community/fcm: 5.0.2
@capacitor/push-notifications: 5.1.1
@ionic/react: 7.7.0
react: 18.2.0
I did try this fork: https://github.com/thuongnv-lib/fcm but it's pretty out of date and no longer builds. Thanks!
So I never did really figure out what I was misunderstanding about deleteInstance(), but with some changes on my end I was able to get refreshToken() working for my purposes. Thanks for the help.