世博会苹果登录反应原生返回空值

Posted

技术标签:

【中文标题】世博会苹果登录反应原生返回空值【英文标题】:expo apple sign in react native returning null values 【发布时间】:2021-02-02 18:26:04 【问题描述】:

我已在我的 react 本机应用程序中使用 Apple 登录。有时有效,有时无效。

当它不工作时,它会返回所有 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;
      
    
  
/>

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

【问题讨论】:

【参考方案1】:

Apple Sign In 仅在首次登录(注册)时发送用户信息。之后,您可以自行存储这些内容并在用户再次登录时重复使用它们。

【讨论】:

如果用户在多个设备上登录和注销怎么办?如何存储每台设备的登录信息? 用户字段是稳定的,因此您可以在注册时使用电子邮件/全名和用户之间的链接存储在任何 api/后端服务中。 docs.expo.io/versions/latest/sdk/apple-authentication/…

以上是关于世博会苹果登录反应原生返回空值的主要内容,如果未能解决你的问题,请参考以下文章

电话不显示反应原生(世博会)上的所有文本

没有这样的表-世博会中的 SQLite 反应原生项目

显示启动画面或加载指示器,直到所有图像都准备好 |世博会|反应原生

世博会弹出反应本机项目上传的apk(由android studio构建)具有比清单文件更多的权限

反应原生空白 MapView

如果没有GPS,则无法使用navigator.geolocation进行反应原生的当前位置