To enable SMS authentication with Firebase, there are a few things we need to configure, that will allow the app to send SMS to the users.
Enable Phone Authentication in Firebase
In Firebase, go to Authentication -> Sign-in method -> Phone Authentication and check the Enable switch.
1. Open the GoogleService-Info.plist file in Xcode, and copy the REVERSED_CLIENT_ID value to the clipboard Make sure that this is your own file which you already downloaded from Firebase at the previous steps. The string will look like this:
2. In Xcode, select the Info.plist file, right click on it -> Open As -> Source Code 3. In Info.plist source code, under CFBundleURLSchemes paste the client ID string copied at the previous step (by replacing the existing one) That’s it. Build and run the app again in Xcode, and now you’ll be able to see real SMS texts getting sent to any phone number.
For Android, setting up SMS Phone Authentication with Firebase is a slightly different than iOS. 1. Generate an upload key keystore For MacOS, simply run the following command from the “android/app” folder of the React Native project:
keytool -genkeypair -v -keystore debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000
When asked for a password, just use android. This will work when running the app in debug mode. For Windows users, you can generate a private signing key using keytool.
keytool must be run from
C:\Program Files\Java\jdkx.x.x_x\bin. If you are building the final app for production (Google Play publishing), follow the official React Native docs on how to generate a production signed binary. If you are still in development mode, you can use the existing debug signing config that we’ve created for you already. You can see the configuration of this signing config in android/app/build.gradle file: 2. Generate a SHA-1 fingerprint certificate from the keystore Simply run the following command (in android/app folder). Use the password android when prompted for it.
keytool -list -v \ -alias androiddebugkey -keystore ~/.android/debug.keystore
keytool -list -v \ -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
This will generate a SHA-1 fingerprint. Copy it to clipboard. You can find more details in the official documentation from Google if you run into any issues. 3. Add the SHA-1 code to Firebase In Firebase, go to Project Settings -> Select the Android app -> Add Fingerprint and place the SHA-1 fingerprint certificate in the corresponding field: That’s it. Build and run the Android app again, and now you’ll be able to receive real SMS texts via Firebase.