微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Apple 登录不适用于 testflight

如何解决Apple 登录不适用于 testflight

目前,我遇到了一个关于苹果登录的问题。众所周知,从 iOS 13 开始,苹果登录是社交登录的强制性要求。我遇到的问题是我实现了在调试模式下工作的苹果登录,但是当我在试飞时提交构建时它不起作用。看起来按钮有它是苹果的错误。请指导我解决这个问题或任何其他出路

谢谢

Apple 登录代码

@IBAction func appleIDSignin(_ sender:UIButton){
SVProgressHUD.show()
self.view.isUserInteractionEnabled = false
currentAppleUser { (userFound) in
    if userFound {
        let userName = KeychainItem.currentUserNameIdentifier
        print(userName)
        let email = KeychainItem.currentEmailIdentifier
        self.socialLogin(Name: userName,Email: email,isMale: 1)
    } else if userFound == false {
        dispatchQueue.main.async {
            SVProgressHUD.dismiss()
            self.view.isUserInteractionEnabled = true
            self.handleAppleIDRequest()
        }
    }
}

func handleAppleIDRequest(){
    let appleIDProvider = ASAuthorizationAppleIDProvider()
    let request = appleIDProvider.createRequest()
    request.requestedScopes = [.fullName,.email]
    let authorizationController = ASAuthorizationController(authorizationRequests: [request])
    authorizationController.delegate = self
    authorizationController.performRequests()
}

检查当前用户

func currentAppleUser( completionHandler:@escaping(_ userFound:Bool)->()){
let appleIDProvider = ASAuthorizationAppleIDProvider()
appleIDProvider.getCredentialState(forUserID: KeychainItem.currentUserIdentifier) { (credentialState,error) in
    switch credentialState {
    case .authorized:
        print("User Valid")
        if KeychainItem.currentUserNameIdentifier == "" || KeychainItem.currentEmailIdentifier == "" {
            completionHandler(false)
        } else {
            completionHandler(true)
        }
        break // The Apple ID credential is valid.
    case .revoked:
        print("revoked")
        completionHandler(false)
        
    case .notFound:
        print("notFound")
        completionHandler(false)
        // The Apple ID credential is either revoked or was not found,so show the sign-in UI.
    
    default:
        break
      }
   }
}

解决方法

您需要为此打开沙盒帐户,您将收到或制作一封电子邮件和密码,以便您可以对其进行测试。和苹果支付一样。您可以通过试飞创建沙盒用户。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。