expo apple sign in react native returning null values

2.3k views Asked by At

I have sign in with apple implemented within my react native app. Some times it works some times it doesn't.

When it's not working it returns all null user values like this:

{
  "authorizationCode": "123456789omitted",
  "email": null,
  "fullName": Object {
    "familyName": null,
    "givenName": null,
    "middleName": null,
    "namePrefix": null,
    "nameSuffix": null,
    "nickname": null,
  },
  "identityToken": "987654321omitted",
  "realUserStatus": 1,
  "state": null,
  "user": "192837465omitted",
}

why would this be happening?

<AppleAuthentication.AppleAuthenticationButton
  buttonType={AppleAuthentication.AppleAuthenticationButtonType.SIGN_IN}
  buttonStyle={AppleAuthentication.AppleAuthenticationButtonStyle.BLACK}
  cornerRadius={5}
  style={{
    width: Constant.width * 0.92,
    height: 44,
  }}
  onPress={async () => {
    try {
      setAppleLoggingIn(true);
      const credential = await AppleAuthentication.signInAsync({
        requestedScopes: [
          AppleAuthentication.AppleAuthenticationScope.FULL_NAME,
          AppleAuthentication.AppleAuthenticationScope.EMAIL,
        ],
      });
      // signed in
      onSignIn(credential);//signs in user via firebase
      setAppleLoggingIn(false);
    } catch (e) {
      if (e.code === "ERR_CANCELED") {
        // handle that the user canceled the sign-in flow
        setAppleLoggingIn(false);
        return {cancelled: true};
      } else {
        // handle other errors
        setAppleLoggingIn(false);
        return {error: true};
      }
    }
  }}
/>

I think it has something to do with this question but I never blocked the app from having access to my apple id...I always "accept" when it asks for permissions. Getting email id value null as response during apple-authentication

2

There are 2 answers

3
Ben Fontan On BEST ANSWER

Apple Sign In only sends user info on the first sign in (sign up). After that, it's up to you to store those and reuse them when the user logs in again.

0
batuhanbag On

you can remove your apple id with this steps: iPhone, setting-Apple ID - password&security - Apps using Apple ID - App name - stop using Apple ID. Then api will give to you new date form.