You can use Firebase Authentication to sign in a user by sending an SMS message to the user's phone. The user signs in using a one-time code contained in the SMS message.
This guide assumes that you have already created your Firebase app and configured your iOS and Android projects as explained in README.
-
Open your project via XCode and navigate to your
GoogleService-Info.plistfile (normaly located at/ios/[YourApp]/Info.plist). Copy yourREVERSED_CLIENT_IDfrom this file. -
Then, click on your xcode project icon (blue one) and under Info tab expand
URL Typespanel. Add new url type and underURL Schemapaste your previously coppiedREVERSED_CLIENT_IDfield value. NOTE: you might see more entries here if you use other social auth providers like Facebook.
-
Run your app and make sure that everything is working. If you run into any trouble it is worth trying to clean your caches and restart XCode.
Android uses keystore system for app signing, if you haven't already done so you will need to generate keystore files for debug (later also release) builds.
In depth information about this is avaliable in Android keystore documentation
-
If you don't have one generate a
debug.keystorefile in yourandroid/appdirectory. These keystore files are required to run android apps in debug and release mode. To generate debug keystore file run following command withinandroid/appfolder (use all default presets when prompted by terminal).keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
-
After you generated your
debug.keystorefile, run following command in the same folder (android/app) to obtain your SHA1 and SHA256 certificate fingerprints. Copy both of them, you will need them in the next step.keytool -list -v -keystore ./debug.keystore -alias androiddebugkey -storepass android -keypass android
-
Once you have your SHA1 and SHA256 certificate fingerprints go yo your Firebase project settings, choose your android app and certificate fingerprints you copied from the previous step.
-
Re-download your
google-services.jsonfile and move it toandroid/appfolder (replace your old file if needed). -
Now clean your android project: In android studio go to
Build>Clean Project. -
Run your app and make sure that everything is working. If you run into any trouble it is worth trying to clean your caches and restart Android Studio.
- In Firebase Console go to
Authentication>Sign In Methodand enable Phone. While on this screen it is a good idea to add your phone number insidePhone numbers for testing (optional)section, otherwise firebase might limit your requests and you will have to wait some time before you can repeatedly sign in.
