Search code examples
androidfirebasereact-nativefirebase-authenticationsha1

React Native Firebase Phone verification silently crash with real phone numbers


I'm having react-native app that is using Firebase to verify user phone numbers. So far, I was testing this by the use of test phone number added to Firebase console and it was working fine. Now, I'm trying to prepare my application for release and I was trying to generated signed release and test phone verification. I did the following:

  1. generated release keystore and added it to android/app
  2. added these parameters to build.gradle android.signincConfigs.release storeFile file('my-release-key.keystore') storePassword 'my-password' keyAlias 'my-alias' keyPassword 'my-password' (basically following these steps https://medium.com/@raguct25/how-to-generate-signed-or-released-apk-file-from-react-native-252bdd1915a2)
  3. used keytool -list ... command to get SHA-1 and add it to Firebase console under my project.
  4. download new google-services.json and added it under android/app
    • generate build using ./gradlew assembleRelease
    • generate signed APK using Android Studio
    • run release in simulator using react-native run-android —variant=release

In each of these builds when firebase is trying to authenticate it's causing app to crash when request to send OTP code is made. My implementation is similar to approach described here https://heartbeat.fritz.ai/implement-firebase-phone-authentication-in-react-native-apps-237959027611

App works well with test phone number.

Error is happening within this code silently, e.g. catch block doesn't catch any error:

   firebase
      .auth()
      .signInWithPhoneNumber(this.state.phone)
      .then(confirmResult => {
        this.setState({ confirmResult })
      })
      .catch(error => {
        alert(error.message)
        console.log(error)
      })

Did I miss something here?


Solution

  • Put this line inside app/build.gradle under dependencies

    implementation "androidx.browser:browser:1.2.0"

    It is because its do reCAPTCHA verification and opens up browser.