invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.74k stars 2.22k forks source link

[🐛] Phone Sign-in Failing with Test Numbers #8171

Open yehya opened 2 days ago

yehya commented 2 days ago

Issue

Phone auth not working with test numbers

+1 555 555 5555 Code: 111111

I use

eas credentials

to get my app SHA, I then put this in firebase & downloaded the GoogleServices file. This is placed in my root directory.

yarn prebuild // npx expo prebuild -p android --clean --yarn
yarn android // npx expo run:android -d

I then run it on an emulator.

The error I get is

LOG  [Firebase] Initializing in mode: DEVELOPMENT
 LOG  [Firebase] Setting up test mode for phone authentication
 LOG  [PhoneAuth] Starting phone verification for: +15555555555
 LOG  [PhoneAuth] Using test verification code: 123456
 LOG  [PhoneVerification] Component mounted
 LOG  [PhoneVerification] Code input completed: 111111
 LOG  [PhoneVerification] Starting verification with code length: 6
 LOG  [PhoneVerification] Attempting to verify code: 111111
 LOG  [PhoneVerification] Calling verifyCode
 LOG  [PhoneAuth] Confirming code: 111111
 LOG  [PhoneAuth] Test mode: any 6-digit code will work
 ERROR  [PhoneAuth] Code verification error: [Error: [auth/unknown] An internal error has occurred. [ Error code:47 ]]
 ERROR  [PhoneVerification] Verification error: [Error: [auth/unknown] An internal error has occurred. [ Error code:47 ]]
 LOG  [PhoneVerification] Verification attempt completed
if (__DEV__) {
            console.log("[Firebase] Setting up test mode for phone authentication");
            auth().settings.appVerificationDisabledForTesting = true;
            auth().settings.forceRecaptchaFlowForTesting = true;
        }

It detects incorrect codes

 LOG  [PhoneVerification] Code input completed: 111112
 LOG  [PhoneVerification] Starting verification with code length: 6
 LOG  [PhoneVerification] Attempting to verify code: 111112
 LOG  [PhoneVerification] Calling verifyCode
 LOG  [PhoneAuth] Confirming code: 111112
 LOG  [PhoneAuth] Test mode: any 6-digit code will work
 ERROR  [PhoneAuth] Code verification error: [Error: [auth/invalid-verification-code] The verification code from SMS/TOTP is invalid. Please check and enter the correct verification code again.]
 ERROR  [PhoneVerification] Verification error: [Error: [auth/invalid-verification-code] The verification code from SMS/TOTP is invalid. Please check and enter the correct verification code again.]
 LOG  [PhoneVerification] Verification attempt completed

My SHA is in firebase.

My project uses expo.

App.json

{
    "expo": {
        "name": "appname",
        "slug": "appname",
        "version": "1.0.0",
        "orientation": "portrait",
        "icon": "./assets/images/icon.png",
        "scheme": "appname",
        "userInterfaceStyle": "light",
        "newArchEnabled": false,
        "ios": {
            "supportsTablet": true,
            "infoPlist": {
                "NSCalendarsUsageDescription": "We need access to your calendar to create reminders for your pickup/delivery times.",
                "NSRemindersUsageDescription": "We need access to your reminders to create reminders for your pickup/delivery times."
            },
            "bundleIdentifier": "com.appname.appname",
            "googleServicesFile": "./GoogleService-Info.plist"
        },
        "android": {
            "permissions": [
                "READ_CALENDAR",
                "WRITE_CALENDAR",
                "android.permission.ACCESS_COARSE_LOCATION",
                "android.permission.ACCESS_FINE_LOCATION",
                "android.permission.FOREGROUND_SERVICE",
                "android.permission.FOREGROUND_SERVICE_LOCATION",
                "android.permission.READ_CALENDAR",
                "android.permission.WRITE_CALENDAR"
            ],
            "googleServicesFile": "./google-services.json",
            "config": {
                "googleMaps": {
                    "apiKey": "YOUR_API_KEY"
                }
            },
            "adaptiveIcon": {
                "foregroundImage": "./assets/images/adaptive-icon.png",
                "backgroundColor": "#ffffff"
            },
            "package": "com.appname.appname"
        },
        "web": {
            "favicon": "./assets/images/favicon.png",
            "output": "single"
        },
        "plugins": [
            [
                "expo-location",
                {
                    "locationWhenInUsePermission": "Allow $(PRODUCT_NAME) to use your location when you're using the app.",
                    "isAndroidForegroundServiceEnabled": true
                }
            ],
            "expo-router",
            [
                "expo-splash-screen",
                {
                    "image": "./assets/splash.png",
                    "imageWidth": 200,
                    "resizeMode": "contain",
                    "backgroundColor": "#ffffff"
                }
            ],
            [
                "expo-font",
                {
                    "fonts": [
                        "./assets/fonts/DMSerifDisplay-Regular.ttf",
                        "./assets/fonts/Engagement-Regular.ttf",
                        "./assets/fonts/Inter-Bold.ttf",
                        "./assets/fonts/Inter-Regular.ttf",
                        "./assets/fonts/Lexend-Bold.ttf",
                        "./assets/fonts/Lexend-ExtraBold.ttf",
                        "./assets/fonts/Lexend-ExtraLight.ttf",
                        "./assets/fonts/Lexend-Light.ttf",
                        "./assets/fonts/Lexend-Medium.ttf",
                        "./assets/fonts/Lexend-Regular.ttf",
                        "./assets/fonts/Lexend-SemiBold.ttf",
                        "./assets/fonts/Outfit-Light.ttf",
                        "./assets/fonts/Outfit-Regular.ttf",
                        "./assets/fonts/Poppins-Regular.ttf",
                        "./assets/fonts/SpaceMono-Regular.ttf",
                        "./assets/fonts/StyleScript-Regular.ttf"
                    ]
                }
            ],
            [
                "expo-calendar",
                {
                    "calendarPermission": "Allow $(PRODUCT_NAME) to access your calendar"
                }
            ],
            "@react-native-firebase/app",
            "@react-native-firebase/crashlytics",
            "@react-native-firebase/auth"
        ],
        "experiments": {
            "typedRoutes": true
        },
        "extra": {
            "router": {
                "origin": false
            },
            "eas": {
                "projectId": "your-project-id"
            }
        },
        "owner": "appname"
    }
}

Project Files

Javascript

Click To Expand

#### `package.json`: ```json { "name": "@your-namespace/customer", "main": "expo-router/entry", "version": "1.0.0", "scripts": { "start": "EXPO_DEBUGGER=true expo start", "dev": "./scripts/start_dev.sh", "doctor": "npx expo-doctor", "android": "npx expo run:android -d", "ios": "expo run:ios", "web": "expo start --web", "test": "jest --watchAll", "lint": "eslint . --fix", "clean-prject": "npx react-native-clean-project", "prebuild": "npx expo prebuild -p android --clean --yarn", "build-android-local": "eas build --profile development --platform android --local", "build-android-cloud": "eas build --profile development --platform android", "debug-credentials": "keytool -list -v -keystore ./android/app/debug.keystore -alias androiddebugkey -storepass android -keypass android", "build-test-apk": "eas build -p android --profile preview" }, "dependencies": { "@expo/vector-icons": "^14.0.4", "@react-native-firebase/app": "^21.6.1", "@react-native-firebase/auth": "^21.6.1", "@react-native-firebase/crashlytics": "^21.6.1", "@react-navigation/bottom-tabs": "^7.0.0", "@react-navigation/native": "^7.0.0", "expo": "^52.0.7", "expo-calendar": "~14.0.2", "expo-crypto": "~14.0.1", "expo-dev-client": "~5.0.2", "expo-font": "^13.0.1", "expo-image": "^2.0.0", "expo-linear-gradient": "^14.0.1", "expo-linking": "~7.0.2", "expo-location": "~18.0.1", "expo-navigation-bar": "~4.0.3", "expo-router": "~4.0.6", "expo-splash-screen": "~0.29.11", "expo-status-bar": "^2.0.0", "expo-system-ui": "~4.0.3", "lodash": "^4.17.21", "react": "18.3.1", "react-dom": "18.3.1", "react-native": "0.76.2", "react-native-google-places-sdk": "^0.1.4", "react-native-maps": "1.18.0", "react-native-reanimated": "^3.16.1", "react-native-remix-icon": "^4.5.0", "react-native-safe-area-context": "4.12.0", "react-native-screens": "^4.0.0", "react-native-svg": "15.8.0", "react-native-web": "~0.19.13", "zustand": "^5.0.1" }, "devDependencies": { "@babel/core": "^7.25.2", "@types/lodash": "^4.17.13", "@types/react": "~18.3.12", "typescript": "^5.3.3" }, "private": true, "volta": { "node": "18.20.5", "yarn": "1.22.22" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [] my application is an AndroidX application? - [] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` info Fetching system and libraries information... System: OS: macOS 15.1 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 1.59 GB / 16.00 GB Shell: version: 3.7.1 path: /usr/local/bin/fish Binaries: Node: version: 18.20.5 path: /var/folders/hz/pcmycg3x45d1c478xmwkv77w0000gn/T/yarn--1733016053938-0.7589446617523361/node Yarn: version: 1.22.22 path: /var/folders/hz/pcmycg3x45d1c478xmwkv77w0000gn/T/yarn--1733016053938-0.7589446617523361/yarn npm: version: 10.8.2 path: ~/.volta/tools/image/node/18.20.5/bin/npm Watchman: version: 2024.11.25.00 path: /usr/local/bin/watchman Managers: CocoaPods: version: 1.16.2 path: /Users/here/.rbenv/shims/pod SDKs: iOS SDK: Platforms: - DriverKit 24.1 - iOS 18.1 - macOS 15.1 - tvOS 18.1 - visionOS 2.1 - watchOS 11.1 Android SDK: API Levels: - "29" - "31" - "33" - "34" - "35" Build Tools: - 30.0.3 - 33.0.0 - 33.0.1 - 34.0.0 - 35.0.0 System Images: - android-35 | Google Play Intel x86_64 Atom - android-35 | Pre-Release 16 KB Page Size Google APIs Intel x86_64 Atom Android NDK: Not Found IDEs: Android Studio: 2024.2 AI-242.23339.11.2421.12550806 Xcode: version: 16.1/16B40 path: /usr/bin/xcodebuild Languages: Java: version: 17.0.13 path: /Users/here/.jenv/shims/javac Ruby: version: 3.2.0 path: /Users/here/.rbenv/shims/ruby npmPackages: "@react-native-community/cli": Not Found react: Not Found react-native: Not Found react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: Not found newArchEnabled: Not found info React Native v0.76.3 is now available (your project is running on v0.76.2). info Changelog: https://github.com/facebook/react-native/releases/tag/v0.76.3 info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.76.3 info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos". Done in 5.18s. ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ X] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `e.g. 5.4.3` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y` & `in package.json`


mikehardy commented 2 days ago

Possible duplicate https://github.com/invertase/react-native-firebase/issues/6457

Everything I see online points to some sort of google cloud permission issue / project setup issue - zero things point to anything this module (in react-native-firebase) could do anything about. I'd approach official firebase support.

You are describing a problem on android so you might try a basic repro from their android quickstart https://github.com/firebase/quickstart-android/tree/master/auth