New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help wanted: firebase.messaging().getToken() returns null #1429
Comments
Could you check the result of |
my solution:
You can have a try. |
The above code prints 'User has fcm permission' |
@cx5168 Thank you, but this still doesn't work for me. Here is my code:
|
@chinalwb In addition, the firebase version of the build.gradle file is recommended to upgrade to the latest.
End of the document to add: I hope you can succeed. |
@chinalwb |
@cx5168 Thanks very much! Thanks again. |
I'll come back to close this thread after I am done with the network problem and double checked. |
I'm also seeing this problem the 1st time I install the app on the actual device. I will need to kill the app then relaunch to get the token successfully. Not great for user experience though. How can we make this more reliable? |
Mobile phones must be able to connect to servers that provide firebase services. |
@cx5168 Got it, thanks! BTW, just FYI, my emulator does provide me the FCM token. |
Hello, in Android 8.0 is not returning the token, there are some solution for this. |
Sometimes I get token = null as well, maybe this issue should be reopen |
Any news in this? Still getting null, tried all methods above |
According to docs, getToken() is deprecated. Other than that, docs state:
|
Ok folks, here's the deal: In
don't forget to import FirebaseApp Tested on emulator, not on real device. |
Mr. @efstathiosntonas please bump the package version, so we can update |
@efstathiosntonas , it is showing this error , please can anyone help , i am using react-native-firebase:4.3.8
|
@faisalpathan have you added google services json and plist from firebase in your project? It seems that firebase is not initiating thus you dont have sender id. |
@efstathiosntonas , google-services.json is already present in android/app folder of the application and also the notification permission is also granted i have just replaced getToken method with above mentioned code , is it correct ? |
@faisalpathan @cx5168 this has nothing to do with this modification, there is something wrong with your setup/configuration. The change I've made is according to docs so there's nothing wrong.
|
@efstathiosntonas , please can you share your configuration and which version of react-native-firebase you are using ? |
@efstathiosntonas You're right. I've tried several times and I can get token normally. Thank you very much. |
@cx5168 can you share your configuration as well ? |
Environment: Packages: (wanted => installed) react-native-firebase: 4.3.8 android/build.gradle: android/app/build.gradle apply plugin: 'com.google.gms.google-services' android/app/google.services.json source: |
@cx5168 , thank you so much for the configuration , Really Appreciated. Still getting the same error as
any solution anyone can help with ? |
@faisalpathan |
I checked the native code , maybe your issue is like me, I resolved by follow this issue , turn on/off push notification capability |
Issue
By following the guide of Cloud Messaging, the following code:
My problem is
getToken()
returns null. Want to know what to do to re-get the token.It prints:
P.S.: I can get the token on my Android Studio emulator, but for the above case, I cannot get the token on my real device, it is a HuaWei Honor 8, runs Android 7.0.
Environment
React Native
version: 0.55.4React Native Firebase
Version: 4.3.0Firebase
Module: messagingtypescript
? noLoving
react-native-firebase
? Please consider supporting them with any of the below:React Native Firebase
andInvertase
on TwitterThe text was updated successfully, but these errors were encountered: