【发布时间】:2020-12-01 08:15:36
【问题描述】:
我按照本指南: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()} />
</>
);
【问题讨论】:
-
对该错误消息进行网络搜索。它出现了很多。您可能配置错误。
-
是的,我尝试用谷歌搜索它,没有帮助,因此我在这里问..
-
由于有很多关于做什么的建议,您可能应该编辑问题以解释您所做的一切都没有帮助。我们需要能够根据您提供的信息重现问题,并且我们无法实际引导您完成每个已知步骤来调试此问题。如果您真的认为您已经尝试了所有方法,则应直接联系 Firebase 支持以获得个性化帮助。 support.google.com/firebase/contact/support
标签: android firebase react-native firebase-authentication