onTokenRefresh与firebase的推送通知有什么不同?
我是firebase的新员工,我是本地人,所以我对这些问题感到抱歉,但我想知道onTokenRefresh与firebase的推送通知有什么不同?,firebase,react-native,firebase-cloud-messaging,Firebase,React Native,Firebase Cloud Messaging,我是firebase的新员工,我是本地人,所以我对这些问题感到抱歉,但我想知道 onTokenRefresh与firebase的推送通知有什么不同 为什么不只与getToken一起使用 为什么onTokenRefresh总是出现在这段代码中,我认为只有当令牌实际更改时,它才会运行这个函数 componentDidMount() { kittensApp.onReady().then(app => { app.messaging().getToken() .then(fcmToken =
componentDidMount() {
kittensApp.onReady().then(app => {
app.messaging().getToken()
.then(fcmToken => {
if (fcmToken) {
console.log('fcmtokenApp', fcmToken)
} else {
console.log('here 2')
}
})
app.messaging().onTokenRefresh(token => {
console.log('refreshtoken', token)
})
})}
控制台.log
)希望能有所帮助。谢谢你的回答……我还有一个小问题,如果用户已经登录并给了我设备令牌,而我保存在服务器上的数据库中,现在用户重新安装了应用程序,但还没有打开应用程序,在这种情况下,设备令牌已更改,数据库中的令牌无效,因此下次我会尝试若要推送通知,它将不起作用……这有什么关系?@TalShani我在react native中的oneSignal也有同样的问题,如果用户登录并重新安装应用程序,现在就可以轻松地注销他(删除令牌)并在JS、本机android活动或iOS中处理卸载/重新安装应用程序可能您可以在服务中处理,但我不确定是否可能(我刚刚跳过了这个案例)。用户必须在重新安装后运行应用程序,以便获得新令牌,您将在服务器端进行更新。如果他不打开应用程序,很遗憾,他不会收到推送通知。