在react native中如何获取注册时的device token

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

当用户注册时如何获取设备令牌 app.The 目的是我想使用 fcm 发送推送通知。有人可以帮忙吗?

当我做同样的事情时,我使用了这个库:https://github.com/evollu/react-native-fcm

顺便说一句,我认为效果很好。

当用户点击注册按钮或其他按钮时,我会:

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

令牌也可以更改,因此每当启动应用程序时,我都会比较 AsyncStorage 中的现有密钥,如果它已更改,我将使用相同的过程来更新密钥后端。

希望这对您有所帮助,祝您好运。