I am integrating the login with Apple but I get an error that crashes the application.
When running the app with the iOS simulator, these problems do not appear, but with the physical device they do. Apparently this method does not give me user data on a physical device. I realize because the console shows this error:
Fatal error: Unexpectedly found nil while unwrapping an Optional value.
And reviewing more in detail I see that I receive a nil to get the name, surname and email of the user in a physical device. But in the simulator, I repeat, if I get this user data.
I attach the part of the code where the problem is presented and also the breakpoint where it is pointed out to me.
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
switch authorization.credential{
case let credentials as ASAuthorizationAppleIDCredential:
let nombre = credentials.fullName?.givenName print("El nombre: ", nombre!)
let apellido = credentials.fullName?.familyName
print("El apellido: ", apellido!)
let mail = credentials.email
var enviaCorreo: String = ""
if mail == nil{
enviaCorreo = "no"
}else{
print("Mail: ", mail!)
enviaCorreo = mail!
}
camposAppleID(mail: enviaCorreo, nombre: nombre!, apellido: apellido!)
break
default:
break
}
}
}
I hope you can help me. Thank you very much for your attention. Greetings.