ios - 反应原生Apple登录卡在IOS的输入密码屏幕中?
问题描述
在 IOS 中输入密码后它显示加载,之后没有任何反应。没有控制台日志?它在 android 中工作正常。
我已经实现了反应原生苹果身份验证的 V2 https://github.com/invertase/react-native-apple-authentication
代码 1
const IOSAppleLogin = async () => {
try {
// performs login request
const appleAuthRequestResponse = await appleAuth.performRequest({
requestedOperation: appleAuth.Operation.LOGIN,
requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME]
});
const credentialState = await appleAuth.getCredentialStateForUser(
appleAuthRequestResponse.user
);
if (credentialState === appleAuth.State.AUTHORIZED) {
console.log('appleAuthRequestResponse', appleAuthRequestResponse);
const response = appleAuthRequestResponse;
console.log('apple-response', response);
// you may also want to send the device's ID to your server to link a device with the account
// identityToken generated
if (response) {
if (response.identityToken) {
let device_identifier = DeviceInfo.getUniqueId();
let details = {
'identity_token': response.identityToken,
'first_name': response.fullName ? response.fullName.givenName : '-',
'last_name': response.fullName ? response.fullName.familyName : '-',
'device_identifier': device_identifier,
device: Platform.OS
};
props.appleLogin({ values: details });
}
}
// user is authenticated
}
} catch (error) {
if (appleAuth.Error.CANCELED === error.code) {
console.log('apple-error-CANCELED', JSON.stringify(error));
} else if (appleAuth.Error.FAILED === error.code) {
console.log('apple-error-FAILED', error);
} else if (appleAuth.Error.NOT_HANDLED === error.code) {
console.log('apple-error-NOT_HANDLED', error);
} else {
console.log('apple-error', error);
}
}
}
代码 2
const IOSAppleLogin = async () => {
try {
// performs login request
const appleAuthRequestResponse = await appleAuth.performRequest({
requestedOperation: appleAuth.Operation.LOGIN,
requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME]
});
console.log('appleAuthRequestResponse', appleAuthRequestResponse);
const response = appleAuthRequestResponse;
console.log('apple-response', response);
// you may also want to send the device's ID to your server to link a device with the account
// identityToken generated
if (response) {
if (response.identityToken) {
let device_identifier = DeviceInfo.getUniqueId();
let details = {
'identity_token': response.identityToken,
'first_name': response.fullName ? response.fullName.givenName : '-',
'last_name': response.fullName ? response.fullName.familyName : '-',
'device_identifier': device_identifier,
device: Platform.OS
};
props.appleLogin({ values: details });
}
}
// user is authenticated
} catch (error) {
if (appleAuth.Error.CANCELED === error.code) {
console.log('apple-error-CANCELED', JSON.stringify(error));
} else if (appleAuth.Error.FAILED === error.code) {
console.log('apple-error-FAILED', error);
} else if (appleAuth.Error.NOT_HANDLED === error.code) {
console.log('apple-error-NOT_HANDLED', error);
} else {
console.log('apple-error', error);
}
}
}
解决方案
我也遇到过这种情况。在这里找到解决方案https://github.com/invertase/react-native-apple-authentication/issues/162#issuecomment-723502035。
基本上,如果您在模拟器上使用 iOS 13 或在真实设备上使用 iOS 14,则只需使用 iOS 13。
推荐阅读
- javascript - 在 HTML 中定义的 DomContentLoaded 中定义的 IIFE 中使用的 Javascript 函数对象原型给出错误
- javascript - 单击以加载更多数据然后单击以隐藏然后再次单击加载不起作用
- android - Android Studio 错误:数据错误循环冗余校验
- json - vue.js 中的错误(从渲染函数返回多个根节点)
- python - 有没有办法让updateview中的时间与django中createview中的时间相同
- python - 在链接时间内使用 tensorflow-gpu cudnn 失败
- python - Python:局部变量、全局变量
- swift - 根据拾取的图像(来自图像选择器)框架更改图像视图框架 SWIFT
- python - loss: nan 何时建立共享单车模型
- python - 谷歌运筹学工具中的目标函数“公平”系数