本文介绍了认证后如何注销苹果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序具有使用Apple登录"帐户功能.我想知道苹果帐户是否有退出功能.

My app has a "Sign in with the Apple" account feature. I am wondering if there is sign out feature from the Apple account.

我尝试了以下方法,但没有成功

I tried the below but doesn't get success

    let request = ASAuthorizationAppleIDProvider().createRequest()

    request.requestedOperation = .operationLogout

    let authorizationController = ASAuthorizationController(authorizationRequests: [request])

    authorizationController.performRequests()

推荐答案

Apple当前仅允许用户执行注销(iOS/watchOS/tvOS)或显示为对我们的许可撤销.他们建议您在使用证书检查撤销之前,先获取凭据的状态,以及是否已删除所有本地信息(删除存储在用户标识符中的用户标识符)(并可能在需要时更改UI;例如,显示登录名)视图).

Apple only allows currently for the user to perform a signout (iOS/watchOS/tvOS) or shown as a revoke of permissions to us. They recommend you get the state of the credentials before use to check for revoke and if that has occurred to delete any local information (Remove the user identifier where ever you have it stored) (And possibly change UI if needed; For example like showing login view).

        let appleIDProvider = ASAuthorizationAppleIDProvider()
    appleIDProvider.getCredentialState(forUserID: KeychainItem.currentUserIdentifier) { (credentialState, error) in
        switch credentialState {
        case .authorized:
            // The Apple ID credential is valid.
            break
        case .revoked:
            // The Apple ID credential is revoked.
            break
        case .notFound:
            // No credential was found, so show the sign-in UI.
            break
        default:
            break
        }
    }

您可以在注销时向用户提供提示,指导他们也撤消其设备的设置并听取更改通知.

You could provide a prompt to the user on signout guiding them to revoke in their device's settings as well and listen for the change notification.

这篇关于认证后如何注销苹果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 14:03