问题描述
我已使用我的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登录仅发送有关第一个登录(注册)的用户信息。之后,由您决定存储这些信息并在用户再次登录时重新使用它们。