简体   繁体   English

React Native Apple 登录卡在 IOS 的输入密码屏幕中?

[英]React native Apple login stuck in enter password screen in IOS?

In IOS after entering the password it shows loading and nothing happens after that.There are no console logs?It's working fine in android.在 IOS 中输入密码后它显示加载,之后没有任何反应。没有控制台日志?它在 android 中工作正常。

I have implemented V2 of react native apple authentication https://github.com/invertase/react-native-apple-authentication我已经实现了反应原生苹果身份验证的 V2 https://github.com/invertase/react-native-apple-authentication

在此处输入图像描述 Tried 2 codes below same issue.在同一问题下尝试了 2 个代码。

Code 1代码 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);
            }
        }
    }

Code 2代码 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);
            }
        }
    }

Had this happen to me as well.我也遇到过这种情况。 Found the solution here https://github.com/invertase/react-native-apple-authentication/issues/162#issuecomment-723502035 .在这里找到解决方案https://github.com/invertase/react-native-apple-authentication/issues/162#issuecomment-723502035

Basically, just use iOS 13 if you are on an emulator or iOS 14 on a real device.基本上,如果您在模拟器上使用 iOS 13 或在真实设备上使用 iOS 14 。

This also happened with me when I am trying to run the code on simulator, Try this on real device it will work.当我尝试在模拟器上运行代码时,这也发生在我身上,在真实设备上尝试它会起作用。 Don't forgot to add Sign In with Apple for both release and debug App in Signing & Capabilities .For this you should have an ADP Account.不要忘记在Signing & Capabilities中为发布和调试应用程序添加Sign In with Apple 。为此,您应该有一个 ADP 帐户。

Thank you.谢谢你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM