在真实设备上使用 Apple 登录无法获取姓名和电子邮件

Cannot get name & email with sign in with Apple on real device

所以我实现了苹果登录,在模拟器上一切正常,我请求email,fullName scopes,authenticate UI显示,我可以得到数据,如下图:

但是在真实设备上测试时(iPadOS 13,iPad 2018),UI没有显示(它不要求名称和UI 上的电子邮件),我无法从响应中获取电子邮件、全名,而且我还可以确认 authorizedScopes 为空,我只能获取用户标识符

我认为这是一个错误,将提交雷达,还在 Apple 开发者论坛上 post 进行了讨论(但他们通常不会批准我的 post,我不会知道为什么)

如果这不是错误,有人可以告诉我如何解决这个问题吗? 谢谢

问题解决了! tl;博士

这是预期的行为

苹果工程师回答 (原文postlink:https://forums.developer.apple.com/thread/121496)

Hi aslkdjalksdjasdasd,

This behaves correctly, user info is only sent in the ASAuthorizationAppleIDCredential upon initial user sign up. Subsequent logins to your app using Sign In with Apple with the same account do not share any user info and will only return a user identifier in the ASAuthorizationAppleIDCredential. It is recommened that you securely cache the initial ASAuthorizationAppleIDCredential containing the user info until you can validate that an account has succesfully been created on your server.

Patrick

2019/12/15 编辑

此行为也记录在 Apple 的 Sign in with Apple 文档中,请查看 documentation

Ensure that your app relays the credentials and user information to your app servers. The API collects this information and shares it with your app the first time the user logs in to the app using Sign in with Apple. If the user then uses Sign in with Apple on another device, the API doesn't ask for the user’s name or email again. It collects the information again only if the user stops using Sign in with Apple and later reconnects to your app.

如果有人第一次存储“用户电子邮件”、“名字”失败,那么他应该按照以下步骤操作:

iPhone 设置 -> Apple Id -> 密码与安全 -> Apple ID 登录 -> {YOUR APP} > 停止使用 Apple ID。