React Native 应用在 iOS 上使用苹果登录时卡在“输入密码”界面?

10
在iOS中输入密码后,它会显示“加载”并且之后什么也不会发生。没有控制台日志?在安卓中运行良好。
我已经实现了React Native苹果认证的V2版本 https://github.com/invertase/react-native-apple-authentication enter image description here 尝试了以下两个代码,出现相同问题。
代码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);
            }
        }
    }
2个回答

6

1
我正在使用iOS 15模拟器,但仍然无法正常工作,并且一直在加载。 - appdev
@appdev 看起来问题仍然存在,只有使用 iOS 13 或真实设备似乎是唯一合法的建议 https://github.com/invertase/react-native-apple-authentication/issues/141#issuecomment-992497099。 - JayMandiadi

0
当我试图在模拟器上运行代码时,我也遇到了这个问题。请尝试在真实设备上运行,它会正常工作。 不要忘记在“签名和能力”中为发布和调试应用程序添加使用Apple登录。为此,您需要一个ADP帐户。
谢谢。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接