0

I followed this guide: https://rnfirebase.io/auth/phone-auth, to add phone auth to my app but it only works with test numbers but when i initiate the signInWithPhoneNumber function with my real number i get this error (even though i tried running the app on my own phone) and configured the sha-1 key and package name to firebase: This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console. [ App validation failed. Is app running on a physical device? ]

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()} />
    </>
  );
  • Do a web search for that error message. It comes up a LOT. You have likely misconfigured something. – Doug Stevenson Aug 11 '20 at 16:01
  • Yeah, i tried to google it, didn't help, hence why I'm asking here.. – Mostafa Elkaramany Aug 11 '20 at 16:28
  • Since there is a **lot** of advice on what to do, you should probably edit the question to explain what all you've done that didn't help. We need to be able to reproduce the issue based on the information you provide, and we can't realistically walk you through each of the known steps to debug this. If you honestly think you have tried everything, you should contact Firebase support directly for personalized assistance. https://support.google.com/firebase/contact/support – Doug Stevenson Aug 11 '20 at 16:53

1 Answers1

0

This error is that you have not added the debug SHA-1 key to firebase. You can add test phone number to firebase.

enter image description here

Or follow this article to get debug SHA-1 key

SHA-1 fingerprint of keystore certificate

Duy Nguyen
  • 238
  • 1
  • 5