用户注销 React Native 应用程序时如何删除 Firebase Cloud Messaging 令牌? [英] How to delete Firebase Cloud Messaging Token when user Log-Out of the React Native application?

查看:66
本文介绍了用户注销 React Native 应用程序时如何删除 Firebase Cloud Messaging 令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 React Native FCM 进行消息传递,当用户注销应用程序时,我想删除 FCM 令牌,以便用户不会再次收到通知.

I use React Native FCM for messaging, and when the user logs out the application I want to delete the FCM token so that the user doesn't get Notified again.

下面是我的注销代码.

_signOutAsync = async () => {
    this.logoutEvent()
    API.post('customer/auth/logout', null, {
      headers: {
        Authorization:
          'Bearer ' + (await AsyncStorage.getItem(Config.ACCESS_TOKEN))
      }
    }).then((response) => {
      console.log(response)
    })
    this.clearData()
  }

谢谢.

推荐答案

只需在注销函数中添加以下给定代码即可.

Simply add below given code in your logout function.

firebase.messaging().deleteToken()

这篇关于用户注销 React Native 应用程序时如何删除 Firebase Cloud Messaging 令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆