react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

getIdToken() never returns

Open MariaSyed opened this issue 8 years ago • 8 comments

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:

  1. Samsung SM-G950U1, Android 8.0.0
  2. OnePlus A3003, Android 8.0.0

Environment

  1. Application Target Platform: iOS & Android

  2. Development Operating System: Android Studio: 3.0.1 Xcode: 9.3.1

  3. Build Tools: android: buildToolsVersion = '27.0.3'

  4. React Native version: 0.50.1

  5. 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"

MariaSyed avatar May 29 '18 07:05 MariaSyed

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 avatar May 29 '18 07:05 Ehesp

@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 avatar May 29 '18 11:05 MariaSyed

@MariaSyed There is now a version 16.0.1 of Firebase Auth - it might be worth trying that?

chrisbianca avatar May 29 '18 12:05 chrisbianca

https://status.firebase.google.com/ There is an issue with Cloud Messaging

Patzelly avatar May 29 '18 12:05 Patzelly

@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 :)

MariaSyed avatar May 29 '18 13:05 MariaSyed

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

chrisbianca avatar May 29 '18 16:05 chrisbianca

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.

Ehesp avatar Jul 18 '18 16:07 Ehesp

this is bug in fire base v 15. Please don't upgrade to latest continue using the old version

ashwath20 avatar Apr 12 '20 19:04 ashwath20