2020年12月21日星期一

React Native Expo app how to unregister from Notifications

In my react native expo app I am successfully registering to the notification service with Notifications.getExpoPushTokenAsync() and it is working without issue, my question is, how do I stop receiving notifications? Is there a way to clear the push token on the device only?

The problem I am having is if a user logs out and a different user logs in on the same device, they will still receive the previous users notifications since the device still is still registered. Notifications.removePushTokenSubscription() seemed like it may work but it only removes the push token listener created with Notifications.addPushTokenListener() which (I think) is unrelated to this issue

My current logout function attempt looks like this:

  const logOutUser = async(notificationToken) => {      if(notificationToken){        var subscription = await Notifications.addPushTokenListener(notificationToken);        await Notifications.removePushTokenSubscription(subscription);      }    }  

Am I thinking about this problem wrong? Thanks!

https://stackoverflow.com/questions/65402743/react-native-expo-app-how-to-unregister-from-notifications December 22, 2020 at 11:05AM

没有评论:

发表评论