getIdToken() never returns
Issue
await firebase.auth().currentUser.getIdToken() never returns for some devices
We recently upgraded our react native project from react-native-firebase v3.3.1 to v4.1.0.
We are using apisauce for our api calls and before each api call, we fetch a firebase token and send that to the server as an authroization header.
We run this function (simplified) to fetch a token with every request
async firebaseToken() {
const currentUser = firebase.auth().currentUser
if (currentUser) {
// reaches here
const idToken = await currentUser.getIdToken()
// never reaches here
return idToken
}
}
This works perfectly on most of our test phones but on two of our devices, it gets stuck on await currentUser.getToken()
These two devices are:
- Samsung SM-G950U1, Android 8.0.0
- OnePlus A3003, Android 8.0.0
Environment
-
Application Target Platform: iOS & Android
-
Development Operating System: Android Studio: 3.0.1 Xcode: 9.3.1
-
Build Tools: android:
buildToolsVersion = '27.0.3' -
React Native version: 0.50.1
-
RNFirebase Version: 4.1.0
android/app/build.gradle:
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-database:15.0.1"
implementation "com.google.firebase:firebase-auth:15.1.0"
implementation "com.google.firebase:firebase-config:15.0.2"
Are you able to plug the device in and debug with logcat on Android Studio to see if there is any issues?
Also wrap the statement in a try catch to see if it's throwing an unhandled error
@Ehesp the original function was in a try catch, the one I posted was simplified. No errors were caught at all. It doesn't return anything.
Either way we just found a stack overflow question asking about the same problem as ours and turns out the Firebase support team found a bug in Firebase Auth 15.1.0
They advised not to update to 15.1.0
https://stackoverflow.com/questions/50222500/firebase-auth-getidtoken-gets-stuck-after-update
@MariaSyed There is now a version 16.0.1 of Firebase Auth - it might be worth trying that?
https://status.firebase.google.com/ There is an issue with Cloud Messaging
@chrisbianca upgrading to 16.0.1 and gradle to 4.0 introduced more errors, exactly like https://github.com/invertase/react-native-firebase/issues/1155
We decided to downgrade to 12.0 Firebase library versions and react-native-firebase 4.0.1 This works for us :)
It would be great if you're able to test the branch I've pushed up which should fix #1155 and hopefully address this issue too. Details are here: https://github.com/invertase/react-native-firebase/issues/1155#issuecomment-392818412
Please refer to https://github.com/invertase/react-native-firebase/issues/1155#issuecomment-392818412 - the release notes of RNFB 4.3 on upgrading the Android build.gradle dependencies.
this is bug in fire base v 15. Please don't upgrade to latest continue using the old version