I started out by following this tutorial to set up 'Sign in with apple' using Firebase:
However, even when I follow this tutorial:
https://www.iosapptemplates.com/blog/ios-development/sign-in-with-apple-swift#comment-37591
Without any reference to Firebase, I can't get past 'Sign up not completed' in the apple Sign in modal, after the facial recognition 'Signing in' spinner runs.
I've added the capability in XCode & in the identifier, tried adding the Key and without the Key as some tutorials don't mention it. I can't seem to find what I'm missing.
Code taken from tutorials above:
import UIKit
import AuthenticationServices
class ViewController: UIViewController, ASAuthorizationControllerDelegate {
let appleButton = ASAuthorizationAppleIDButton(type: .continue, style: .black)
override func viewDidLoad() {
super.viewDidLoad()
setupAppleButton()
}
func setupAppleButton() {
view.addSubview(appleButton)
appleButton.cornerRadius = 12
appleButton.addTarget(self, action: #selector(handleAppleIdRequest), for: .touchUpInside)
appleButton.translatesAutoresizingMaskIntoConstraints = false
appleButton.heightAnchor.constraint(equalToConstant: 50).isActive = true
appleButton.widthAnchor.constraint(equalToConstant: 235).isActive = true
appleButton.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
appleButton.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -70).isActive = true
}
@objc func handleAppleIdRequest() {
let appleIDProvider = ASAuthorizationAppleIDProvider()
let request = appleIDProvider.createRequest()
request.requestedScopes = [.fullName, .email]
let authorizationController = ASAuthorizationController(authorizationRequests: [request])
authorizationController.delegate = self
authorizationController.performRequests()
}
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
if let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential {
let userIdentifier = appleIDCredential.user
let fullName = appleIDCredential.fullName
let email = appleIDCredential.email
print("User id is \(userIdentifier) \n Full Name is \(String(describing: fullName)) \n Email id is \(String(describing: email))")
}
}
func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
// Handle error.
print("error \(error.localizedDescription)")
}
}
It was an issue Apple-side, I tried everything yesterday it didn't work and now it's working today. :)