expo apple登录react本机返回空值

9nvpjoqh  于 2023-04-12  发布在  React
关注(0)|答案(2)|浏览(160)

我在我的react native应用程序中实现了苹果登录。有时它能用,有时不能用。
当它不工作时,它返回所有null用户值,如下所示:

{
  "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",
}

为什么会这样

<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};
      }
    }
  }}
/>

我认为这与这个问题有关,但我从来没有阻止应用程序访问我的苹果ID ......当它要求权限时,我总是“接受”。Getting email id value null as response during apple-authentication

y1aodyip

y1aodyip1#

Apple Sign In仅在第一次登录时发送用户信息。之后,由您来存储这些信息,并在用户再次登录时重新使用它们。

kmynzznz

kmynzznz2#

你可以通过以下步骤删除你的Apple ID:iPhone,设置-Apple ID -密码和安全-使用Apple ID的应用程序-应用程序名称-停止使用Apple ID。然后API会给予你新的日期形式。

相关问题