ios – Signal In with Apple No Credential Obtainable


I’m making an attempt to implement a Signal In with Apple button to signal customers in or create them an account relying on in the event that they’re new or not. When utilizing my very own system I can log into any account simply nice utilizing the ‘Signal In with Apple’ button, however when making an attempt with a unique system I get this error: FAILED: The operation couldn’t be accomplished. No credentials obtainable for login.

I am not sure what this actually means or the right way to repair it. Here is my code:

@objc non-public func appleSignInPressed() {
    let supplier = ASAuthorizationAppleIDProvider()
    let request = supplier.createRequest()
    request.requestedScopes = [.email, .fullName]
            
    let requests = [request, ASAuthorizationPasswordProvider().createRequest()]
    let controller = ASAuthorizationController(authorizationRequests: requests)
    controller.delegate = self
    controller.presentationContextProvider = self
    controller.performRequests()
}



extension WelcomeViewController: ASAuthorizationControllerDelegate {
    func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
        swap authorization.credential {
        case let passwordCredential as ASPasswordCredential:
            let username = passwordCredential.person
            let password = passwordCredential.password
            viewModel.didTouchLoginButton(with: username, and: password, feeds: [], referralLink: nil)
        case let credentials as ASAuthorizationAppleIDCredential:
            
            let givenName = credentials.fullName?.givenName ?? "person"
            guard let electronic mail = credentials.electronic mail else {
                return
            }
            print(givenName + " " + electronic mail)
        default:
            startSignUpFlow()
        }
    }
    
    func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
        print("FAILED: (error.localizedDescription)")
    }
}

Leave a Reply