简体   繁体   中英

How to get the device token at the time of registration in react native

How do i get the device token when a user is registered in an app.The purpose is that i want to send push notification using fcm. Can anybody please help ?

When I did kinda the same thing I went with this lib: https://github.com/evollu/react-native-fcm

Which I think works great btw.

When the user clicks on the register button or whatever, I do:

FCM.getFCMToken().then(token => {
    //Send register request
});

The token can change as well, so whenever the app is started I compare the existing key from AsyncStorage and if it has changed I'll use the same procedure to update the key backend.

Hope this helps, good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM