[英]React-Native Android FCM: Didn't get a token
I am using react-native-fcm into my React-Native application. 我在我的React-Native应用程序中使用react-native-fcm 。 I am using below method to get device token for the push.
我使用下面的方法来获取推送的设备令牌。
FCM.getFCMToken().then((token) => {
alert('FCM Token: ' + token);
console.log(token);
});
The issue is, I am getting a token in iPhone application, but when I tried in Android, the method is not called. 问题是,我在iPhone应用程序中获得了一个令牌,但是当我在Android中尝试时,该方法未被调用。
I follow each and every step which is suggested by react-native-fcm. 我遵循react-native-fcm建议的每一步。 Can anyone help me to solve the issue?
任何人都可以帮我解决这个问题吗?
It seems that you forget to initialize the Firebase from Android native side. 您似乎忘了从Android原生端初始化Firebase。 I encounter with same issue.
我遇到同样的问题。 Below is the which help to solve the issue.
以下是有助于解决问题的方法。 Checkout my code:
查看我的代码:
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
try {
FirebaseApp.initializeApp(this);
}
catch (Exception e) {
}
}
Just add FirebaseApp.initializeApp(this); 只需添加FirebaseApp.initializeApp(this); into onCreate() method.
进入onCreate()方法。
Cheers... 干杯...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.