微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

EXPO Apple登录响应本机返回空值

如何解决EXPO Apple登录响应本机返回空值

我已使用我的react本机应用程序中实现的apple登录。有时候它有时会起作用。

当它不工作时,将返回所有空用户值,如下所示:

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

我认为这与这个问题有关,但我从未阻止过该应用程序访问我的Apple ID ...在请求权限时,我总是“接受”。 Getting email id value null as response during apple-authentication

解决方法

Apple登录仅发送有关第一个登录(注册)的用户信息。之后,由您决定存储这些信息并在用户再次登录时重新使用它们。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。