我是一个firebase和react-native的新手,所以对于问题感到抱歉,但我想知道。
what is the different between onTokenRefresh to getToken in push notification with firebase?
why not use only with getToken?
why onTokenRefresh is always occurs in this code, I thought it will run this function only if the token actually changed...
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) }) })}
- another question is in case I want to get the token and send it to the server to save it in the database for pushing notification in the future in what function I should use with (the get token or the refresh)? and how can I make sure that in case the token change (by updating the app or reinstall) it will send the new token to the server? or there is any way to keep the token new without make the user open the app?
感谢您的帮助!