I am getting Email and FullName as nil values when I am trying to SignIn with Apple

Viewed 3645

I have implemented Apple SignIn in one of my application. But when user selects hide my email, then i am getting Email and FullName as nil values. Can anyone please help me on this?

2 Answers

Did you aware of defining request scopes while you were performing request?

Your code should be some how similar to this:

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

And when you receive the response, after converting it to ASAuthorizationAppleIDCredential, You can see fullname and email address by printing them out :

func authorizationController(controller: ASAuthorizationController,
                             didCompleteWithAuthorization authorization: ASAuthorization) {
    switch authorization.credential {
    case let appleIDCredential as ASAuthorizationAppleIDCredential:

        debugPrint(appleIDCredential.email) //prints either 'email' or 'proxied email'
        debugPrint(appleIDCredential.fullName) //prints name 'object'

    default:
        break
    }
}

Edit: If problem persists, go to settings -> profile -> password and security -> apps using your apple id find your app and revoke its access and try again!

Related