更新时间:2021-07-31 22:48:31
Recapcha 是可选的,您可以在没有它的情况下使用手机身份验证.
Recapcha is optional you are able to use phone auth without it.
const confirmResult = await auth().signInWithPhoneNumber('+' + phone);
setState(confirmResult);
手动确认代码
if (confirmResult && receivedcode) {
const user = await confirmResult.confirm(receivedcode);
if (user) { //do some staff like login }
}
要自动确认,只需将以下代码放入useEffect
函数中即可.
to auto confirm just put the following code inside useEffect
function.
unsubscribe = auth().onAuthStateChanged(user => {
if (user) { //do some staff like login }
});
如果您不知道 auth
来自哪里:
If you dont know where auth
comes from:
import auth from '@react-native-firebase/auth';