通过电话号码登录电话的不同操作

时间:2020-04-07 12:25:20

标签: firebase react-native firebase-authentication

如何解决Firebase中通过电话号码进行身份验证的问题?

  • 某些手机会自动确认发送到短信的密码

  • 在某些情况下,您必须手动编写

使其正常工作的最佳实践是什么?

async function signInWithPhoneNumber(phoneNumber) {
    const confirmation = await auth().signInWithPhoneNumber(phoneNumber);
    setConfirm(confirmation);
}

async function confirmCode(code) {
    try {
        await confirm.confirm(code).then((user) => {
            // Logic when confirmed
        })
    } catch (error) {
        console.log('Invalid code.');
    }
}

当我输入正确的代码时,confirmCode函数中有一些逻辑

0 个答案:

没有答案
相关问题