我遵循了以下指南:https://rnfirebase.io/auth/phone-auth,将电话身份验证添加到我的应用程序中,但它仅适用于测试号码,但是当我使用我的真实号码启动signInWithPhoneNumber函数时,却出现此错误(即使我尝试运行应用程式),并将sha-1键和套件名称设定为firebase:此应用程式无权使用Firebase验证。请确认在Firebase控制台中配置了正确的软件包名称和SHA-1。 [应用验证失败。应用程序是否在物理设备上运行? ]
const [confirm, setConfirm] = useState(null);
const [num, setNum] = useState('');
const [code, setCode] = useState('');
// Handle the button press
async function signInWithPhoneNumber(phoneNumber) {
const confirmation = await auth().signInWithPhoneNumber(phoneNumber);
setConfirm(confirmation);
}
async function confirmCode() {
try {
await confirm.confirm(code);
} catch (error) {
console.log('Invalid code.');
}
}
if (!confirm) {
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Input
placeholder='Enter phone number'
value={num}
onChangeText={(text) => setNum(text)}
leftIcon={
<Icon
name='user'
size={24}
color='black'
/>
}
/>
<Button
title="Phone Number Sign In"
onPress={() => signInWithPhoneNumber(num)}
/>
</View>
);
}
return (
<>
<TextInput value={code} onChangeText={text => setCode(text)} />
<Button title="Confirm Code" onPress={() => confirmCode()} />
</>
);
答案 0 :(得分:0)
此错误是您尚未将调试SHA-1密钥添加到firebase。您可以将测试电话号码添加到Firebase。
或按照本文获取调试SHA-1密钥