React 本机 Apple 登录卡在 IOS 中的输入密码屏幕?
React native Apple login stuck in enter password screen in IOS?
在 IOS 中输入密码后显示正在加载,在 that.There 后没有任何反应是没有控制台日志?在 android 中工作正常。
我实现了react native apple authentication V2
https://github.com/invertase/react-native-apple-authentication
在同一问题下尝试了 2 个代码。
代码 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。
当我尝试 运行 模拟器上的代码时,这也发生在我身上,在真实设备上试试这个它会工作。
不要忘记在 Signing & Capabilities 中为发布和调试应用程序添加 Sign In with Apple。为此,您应该有一个 ADP 帐户。
谢谢。
在 IOS 中输入密码后显示正在加载,在 that.There 后没有任何反应是没有控制台日志?在 android 中工作正常。
我实现了react native apple authentication 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。
当我尝试 运行 模拟器上的代码时,这也发生在我身上,在真实设备上试试这个它会工作。 不要忘记在 Signing & Capabilities 中为发布和调试应用程序添加 Sign In with Apple。为此,您应该有一个 ADP 帐户。
谢谢。