[🐛] Bug Report Title - auth()?.currentUser.getIdToken(true) returns null to different users (80% on iOS)
Issue
I am using @react-native-firebase/auth:18.9.0 and my react-native version is 0.70.0 and in our application, we are managing sessions through JWT tokens but the issue is some times the method to retrieve the token on app launch returns null even the user was recently signed in. This is happening to multiple users and they are getting signed out without even doing anything.
The exact method I am using is as below
import auth from "@react-native-firebase/auth"; const token = await auth().currentUser?.getIdToken(true);
So the issue is the currentUser is not present in the auth that's why we are not getting the refresh token.
Describe your issue here
Project Files
Javascript
Click To Expand
package.json:
{ "name": "myapp", "version": "0.0.1", "private": true, "scripts": { "android": "npx react-native run-android", "ios": "react-native run-ios", "start": "npx react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@notifee/react-native": "7.8.0", "@react-native-community/blur": "^4.3.2", "@react-native-community/checkbox": "^0.5.17", "@react-native-community/clipboard": "^1.5.1", "@react-native-community/netinfo": "^11.1.0", "@react-native-firebase/analytics": "^18.9.0", "@react-native-firebase/app": "^18.9.0", "@react-native-firebase/auth": "^18.9.0", "@react-native-firebase/crashlytics": "^18.9.0", "@react-native-firebase/dynamic-links": "^18.9.0", "@react-native-firebase/messaging": "^18.9.0", "@react-native-picker/picker": "^2.4.8", "@react-navigation/bottom-tabs": "6.0.7", "@react-navigation/native": "6.0.2", "@react-navigation/native-stack": "6.1.0", "@reduxjs/toolkit": "^1.8.6", "@twotalltotems/react-native-otp-input": "1.3.11", "@types/react-native-vector-icons": "6.4.9", "@veriff/react-native-sdk": "^3.1.0", "@volkenomakers/react-native-country-picker": "^1.0.0", "add": "^2.0.6", "appcenter": "^5.0.0", "appcenter-analytics": "^5.0.1", "appcenter-crashes": "^5.0.1", "axios": "0.21.4", "babel-plugin-module-resolver": "4.1.0", "crypto-js": "^4.2.0", "date-fns": "2.24.0", "eslint-import-resolver-typescript": "2.4.0", "formik": "^2.4.5", "fuse.js": "^6.6.2", "loadsh": "^0.0.4", "lottie-ios": "3.4.0", "lottie-react-native": "^5.1.6", "metro-config": "^0.80.0", "mixpanel-react-native": "^2.4.0", "native-base": "^3.4.28", "react": "18.1.0", "react-native": "0.70.0", "react-native-animatable": "^1.3.3", "react-native-appsflyer": "^6.13.0", "react-native-auto-height-image": "^3.2.4", "react-native-background-timer": "^2.4.1", "react-native-biometrics": "3.0.1", "react-native-code-push": "^7.0.4", "react-native-contacts": "^7.0.8", "react-native-country-picker-modal": "^2.0.0", "react-native-currency-picker": "^1.0.5", "react-native-curved-bottom-bar": "^3.2.7", "react-native-dashed-line": "^1.1.0", "react-native-date-picker": "^5.0.2", "react-native-device-info": "^10.12.0", "react-native-dialog": "^9.2.1", "react-native-dropdown-picker": "^5.4.2", "react-native-email-link": "^1.14.8", "react-native-encrypted-storage": "4.0.3", "react-native-fbsdk-next": "^12.1.2", "react-native-get-random-values": "^1.11.0", "react-native-image-picker": "^7.0.3", "react-native-in-app-review": "^4.3.3", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-launcher-kit": "^1.0.4", "react-native-linear-gradient": "^2.8.3", "react-native-modal": "^13.0.1", "react-native-paper": "^4.12.2", "react-native-permissions": "^4.1.2", "react-native-phone-number-input": "2.1.0", "react-native-pin-view": "^3.0.2", "react-native-plaid-link-sdk": "^10.4.0", "react-native-progress": "^5.0.0", "react-native-raw-bottom-sheet": "^2.2.0", "react-native-reanimated": "^2.14.4", "react-native-safe-area-context": "4.9.0", "react-native-screens": "3.25.0", "react-native-share": "^9.4.1", "react-native-status-bar-height": "^2.6.0", "react-native-storage": "1.0.1", "react-native-svg": "14.0.0", "react-native-swiper": "^1.6.0", "react-native-toast-notifications": "^3.2.3", "react-native-user-inactivity": "1.2.0", "react-native-vector-icons": "^10.0.3", "react-native-version-check": "^3.4.7", "react-native-webview": "^13.6.3", "react-query": "^4.0.0", "react-redux": "^8.0.4", "rn-fetch-blob": "^0.12.0", "uuid": "^9.0.1", "yarn": "^1.22.19", "yup": "^1.3.3" }, "devDependencies": { "@babel/core": "7.12.9", "@babel/preset-env": "^7.14.0", "@babel/runtime": "7.12.5", "@react-native-community/eslint-config": "3.0.0", "@tsconfig/react-native": "^2.0.2", "@types/jest": "^29.2.1", "@types/react": "^18.0.24", "babel-jest": "^29.2.1", "eslint": "^8.19.0", "jest": "^29.2.1", "metro-react-native-babel-preset": "0.73.5", "prettier": "^2.4.1", "react-test-renderer": "18.2.0", "typescript": "4.8.4", "@types/react-test-renderer": "^18.0.0", "@types/react-native": "^0.71.6", "react-native-codegen": "0.0.7", "react-native-svg-transformer": "^1.0.0" }, "jest": { "preset": "react-native" } }
# N/A
firebase.json for react-native-firebase v6:
# N/A
iOS
Click To Expand
ios/Podfile:
- [ ] I'm not using Pods
- [x] I'm using Pods and my Podfile looks like:
# N/A
AppDelegate.m:
// N/A
Android
Click To Expand
Have you converted to AndroidX?
- [ ] my application is an AndroidX application?
- [ ] I am using
android/gradle.settingsjetifier=truefor Android compatibility? - [ ] I am using the NPM package
jetifierfor react-native compatibility?
android/build.gradle:
// N/A
android/app/build.gradle:
// N/A
android/settings.gradle:
// N/A
MainApplication.java:
// N/A
AndroidManifest.xml:
<!-- N/A -->
Environment
Click To Expand
react-native info output:
OUTPUT GOES HERE
-
Platform that you're experiencing the issue on:
- [ ] iOS
- [ ] Android
- [ ] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [x] Both
-
react-native-firebaseversion you're using that has this issue:-
e.g. 5.4.3
-
-
Firebasemodule(s) you're using that has the issue:-
e.g. Instance ID
-
-
Are you using
TypeScript?-
Y/N&VERSION
-
- 👉 Check out
React Native FirebaseandInvertaseon Twitter for updates on the library.