在 React Native 中使用 Apple 登录返回 null [英] Sign in with Apple in React Native returning null

查看:110
本文介绍了在 React Native 中使用 Apple 登录返回 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 React Native 中使用 Apple 登录时遇到问题.起初它返回带有值的电子邮件和名称,但在第二次尝试中它现在返回空值.

I'm having a problem with Sign in with Apple in React Native. At first it is returning email and name with value but in second attempt it is now returning null.

第一次尝试:

"email": c@gmail.com, "fullName": {"familyName": admin, "givenName": admin, "middleName": null, "namePrefix": null, "nameSuffix": null, "nickname": null},

第二次尝试:

"email": null, "fullName": {"familyName": null, "givenName": null, "middleName": null, "namePrefix": null, "nameSuffix": null, "nickname": null},

如何防止这种情况发生以及如何使用注销?谢谢!

How to prevent this from happening and also how to use logout? Thank you!

推荐答案

使用 Apple 登录,您只会在首次登录时获得电子邮件/姓名.然后您有责任存储该信息.来源:

With Sign in with Apple, you only get the email/name on first login. It's your responsibility to then store that information. Source:

只有当用户第一次通过您的应用使用 Apple 登录时,身份验证服务器才会返回用户状态.后续尝试不会返回此用户状态的任何信息,例如在断开连接和重新连接后或从其他设备返回.

The identification servers return the user status only when the user first uses Sign in with Apple with your app. Subsequent attempts don’t return any information for this user status, such as after a disconnect and reconnect occurs or from other devices.

https://developer.apple.com/documentation/sign_in_with_apple/sign_in_api/in_apple_rest_api/authenticating_users_with_sign_in_with_apple

另外:https://developer.apple.com/forums/thread/121496

就注销而言,您不必一定通过使用 Apple 登录来执行此操作.如果您将凭据存储在设备上,则应从存储它们的任何位置清除它们.此外,如果您将凭据用于其他服务(如 Firebase),您当然可以退出该服务.

In terms of logging out, you don't necessarily do this with Sign in With Apple. If you're storing credentials on the device, you should purge them from wherever they're being stored. Also, if you're using the credentials for another service (like Firebase), you can certainly log out of that service.

你没有说你为此使用了什么库,但如果它是re​​act-native-apple-authentication,你可能想参考这个关于注销行为的线程:https://github.com/invertase/react-native-apple-authentication/issues/10#issuecomment-611532131

You don't say what library you're using for this, but if it's react-native-apple-authentication, you may want to refer to this thread about logout behavior: https://github.com/invertase/react-native-apple-authentication/issues/10#issuecomment-611532131

如果在 iOS 设备上,用户可以通过设置"应用撤销使用 Apple 登录"访问权限.另请参阅此相关 SO 问题:从 Apple-Sign In 注销

If on an iOS device, the user can revoke Sign In With Apple access via the Settings app. See also this related SO question: Logout from Apple-Sign In

这篇关于在 React Native 中使用 Apple 登录返回 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆