react-native - 世博苹果登录反应原生返回空值
问题描述
我已经在我的 react 本机应用程序中实现了苹果登录。有时它起作用,有时它不起作用。
当它不工作时,它会返回所有 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……当它请求权限时,我总是“接受”。在苹果身份验证期间获取电子邮件 ID 值 null 作为响应
解决方案
Apple Sign In 仅在首次登录(注册)时发送用户信息。之后,由您来存储它们并在用户再次登录时重复使用它们。
推荐阅读
- javascript - 在从 API 返回的 JSON 对象内的数组中查找具有重复值的条目
- laravel - 致命错误:未捕获的 UnexpectedValueException:无法打开流或文件“/var/www/appname/storage/logs/lumen.log”
- google-chrome - 如何在 Web 浏览器上使用智能卡
- javascript - 将几个 cookie 的值插入隐藏的表单字段
- mysql - 水平合并两个查询结果
- ios - 在 UITableview swift 中使用 UILabel 和 UIWebView 设置 heightForRow
- collections - 绑定到动态创建的输入的视图模型集合
- hyperledger-fabric - REST API 上的 Hyperledger 错误 500:ENDORSEMENT_POLICY_FAILURE
- javascript - ES6 使用导出和导入时出错
- asp.net - OAuthAuthorizationServerProvider 在 asp.net core 2.1 中是否可用?