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.67k stars 2.21k forks source link

verifyPhoneNumberForMultiFactor throw error auth/internal-error #8052

Open osvald0 opened 4 days ago

osvald0 commented 4 days ago

I'm trying to setup 2FA authentication on my react native application but verifyPhoneNumberForMultiFactor throw auth/internal-error on iOS.

Here is the code:

  async function send2FaVerificationCodeForEnroll(phoneNumber: string): Promise<void> {
    try {
      if (auth().currentUser) {
        const newMultiFactorUser = auth().multiFactor(auth().currentUser!);
        const session = await newMultiFactorUser?.getSession();
        if (session) {
          const phoneOptions = { phoneNumber, session };
          const newVerificationId = await auth().verifyPhoneNumberForMultiFactor(phoneOptions);
          setVerificationId(newVerificationId);
          setMultiFactorUser(newMultiFactorUser);
          navigate(Screen.TWO_FACTOR_VERIFICATION, { is2FaEnroll: true });
        }
      }
    } catch (error) {
      setAuthError((error as AppError).code);
    }
  }

Info:

System: OS: macOS 14.6.1 CPU: (10) arm64 Apple M1 Pro Memory: 112.91 MB / 32.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 20.16.0 path: ~/.nvm/versions/node/v20.16.0/bin/node Yarn: version: 3.6.4 path: ~/.yarn/bin/yarn npm: version: 10.8.1 path: ~/.nvm/versions/node/v20.16.0/bin/npm Watchman: version: 2024.09.23.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.15.2 path: /Users/osvaldo/.rvm/gems/ruby-2.7.6/bin/pod SDKs: iOS SDK: Platforms:


My package.json:

{ "name": "XXX", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "@react-native-async-storage/async-storage": "^1.23.1", "@react-native-clipboard/clipboard": "^1.14.2", "@react-native-community/blur": "^4.4.0", "@react-native-firebase/app": "^21.0.0", "@react-native-firebase/auth": "^21.0.0", "@react-native-firebase/dynamic-links": "^21.0.0", "@react-native-masked-view/masked-view": "^0.3.1", "@react-native/metro-config": "^0.75.4", "@react-navigation/native": "^6.1.18", "@react-navigation/native-stack": "^6.11.0", "@react-navigation/stack": "^6.4.1", "@sentry/react-native": "^5.33.1", "@tanstack/react-query": "^5.28.9", "axios": "^1.6.8", "dayjs": "^1.11.10", "deprecated-react-native-prop-types": "^5.0.0", "mustache": "^4.2.0", "qs": "^6.12.0", "react": "^18.3.1", "react-native": "^0.75.4", "react-native-branch": "^6.2.2", "react-native-config": "^1.5.3", "react-native-device-info": "^10.13.1", "react-native-gesture-handler": "^2.20.0", "react-native-linear-gradient": "^2.8.3", "react-native-modal": "^13.0.1", "react-native-reanimated": "^3.15.4", "react-native-render-html": "^6.3.4", "react-native-safe-area-context": "^4.9.0", "react-native-screens": "^3.34.0", "react-native-skeleton-placeholder": "^5.2.4", "react-native-snap-carousel": "latest", "react-native-spinkit": "^1.5.1", "react-native-splash-screen": "^3.3.0", "react-native-sqlite-storage": "^6.0.1", "react-native-svg": "^15.1.0", "react-native-vector-icons": "^10.0.3", "react-native-webview": "^13.8.4", "rn-tooltip": "^3.0.3" }, "devDependencies": { "@babel/core": "^7.25.7", "@babel/plugin-proposal-class-properties": "^7.18.6", "@babel/plugin-proposal-private-methods": "^7.18.6", "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@babel/preset-env": "^7.25.7", "@babel/runtime": "^7.25.7", "@react-native-community/eslint-config": "^3.2.0", "@tsconfig/react-native": "^2.0.2", "@types/jest": "^29.2.1", "@types/mustache": "^4.2.2", "@types/qs": "^6.9.7", "@types/react": "^18.3.11", "@types/react-native-snap-carousel": "^3.8.11", "@types/react-native-sqlite-storage": "^5.0.2", "@types/react-native-vector-icons": "^6.4.13", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.2.1", "babel-plugin-module-resolver": "^5.0.2", "eslint": "^8.19.0", "jest": "^29.2.1", "metro-react-native-babel-preset": "^0.77.0", "prettier": "^2.4.1", "react-native-svg-transformer": "^1.3.0", "react-test-renderer": "18.2.0", "typescript": "^5.6.2" }, "jest": { "preset": "react-native" } }

mikehardy commented 4 days ago

Not sure if this will fit your case, but phone codes are (I believe) only available for people on Blaze plans at the moment - putting the billing hurdle in place was required to stop abuse if I understand correctly. Make sure you are on a plan that includes phone auth, if you are not already

osvald0 commented 4 days ago

Oh, We are using the Spark plan. I'll upgrade and check. Thanks!