简体   繁体   中英

How can I create login and sign up using phone number with firebase android studio?

Is it possible to make Android app login with a phone number and password (not email and password) using Firebase Realtime Database?

There is a phone number sign-in method in firebase authentication where users can login with phone number and otp.

Yes it is possible.

First add your project to Firebase. Follow this You need to integrate firebase sdk for your app.

implementation 'com.google.firebase:firebase-auth:19.1.0'

Enable phone number authentication in Firebase console.

Use this code to send a sms for authentication.

PhoneAuthProvider.getInstance().verifyPhoneNumber(
    phoneNumber,        // Phone number to verify
    60,                 // Timeout duration
    TimeUnit.SECONDS,   // Unit of timeout
    this,               // Activity (for callback binding)
    mCallbacks);        // OnVerificationStateChangedCallbacks

For callback and more info, Read the official documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM