react-native-fcm: Device Token is null in some devices?

Is it possible that device_token can be null in some android devices?

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 14
  • Comments: 26 (4 by maintainers)

Most upvoted comments

I keep having a null registration id on application first boot. Is there any news about that?

Try to change the device language.It worked for me 😃

I just figure out that in my case the problem is the company proxy server. The proxy was blocking the request to firebase and after I configure the proxy server properly to not block my device requests everything woks fine. I know this is a particular case but maybe can help someone.

I made THIS MODIFICATIONS on my forked version of this repo, this code force the refresh of token on firebase server. I really do not test yet, so if someone wants to implement this and do more tests, just feel free to do that.

@evollu I have the same issue here and after some researches I think that Firebase just send the device token in this particular cases:

  1. First time that the app was open on device (just the first time);
  2. Security reasons that made Firebase change the token by it self;
  3. Manually Uninstall/Install app again on device;

But in my case for example, the token was generated on first time that the app was installed, after that, never more! I tried to uninstall/install the app and nothing happends! If anyone solve this problem, please, tell me, cause I have research everywhere and can’t find anything.

I solved this problem for my case. But I’m using Swift (iOS). After re-installing app and other actions my token was nil. I needed to wait didRefreshRegistrationToken function. So, I’m ignoring this nil with guard let token = Messaging.messaging().fcmToken else { return } and after this function func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) { is getting called. Hope it helps someone

firebase class file

    final Intent intent = new Intent("tokenReceiver");
    final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
    intent.putExtra("token",refreshedToken);
    broadcastManager.sendBroadcast(intent);
    storeToken(refreshedToken);
    //sendRegistrationToServer(refreshedToken);

MainActivity LocalBroadcastManager.getInstance(this).registerReceiver(tokenReceiver, new IntentFilter(ā€œtokenReceiverā€));

BroadcastReceiver tokenReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { token = intent.getStringExtra(ā€œtokenā€); if(token != null) { }

	}
};

This code working fine

can you try with Firebase native example? If you still see it, fire a bug to them

@evollu After try a lot of things to works on my device, I run in my emulator, and works. After that, I run in my device again and (I don’t know why) works too and (I don’t know why again) still working! ¬¬

I will try the native sample project anyway and I come back here to say what happends.

Tks a lot.