4

I am using react-native-fcm into my React-Native application. 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.

I follow each and every step which is suggested by react-native-fcm. Can anyone help me to solve the issue?

Lauren Rutledge
  • 1,195
  • 5
  • 18
  • 27
Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56

1 Answers1

1

It seems that you forget to initialize the Firebase from Android native side. 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); into onCreate() method.

Cheers...

Brijesh Shiroya
  • 3,323
  • 1
  • 13
  • 20