ios - Sign-in With Apple Didn t get privaterelay appleid com when hide email in Simulator

0 votes

I'm working on Apple Sign In in Simulator iOS 13.4.1 and XCode Version 11.4.1.

I used to get privaterelay.appleid.com when Hide Email before but after changing my Laptop and try to test Apple Sign In in Simulator again, I got nil result. For other email when I didn't activate Hide Email it's still working and not give me any nil result.

Here my code:

// Create class for object first
class AppleUser{
    var id: String?
    var firstName: String?
    var lastName: String?
    var email: String?

    @available(iOS 13.0, *)
    init(credentials: ASAuthorizationAppleIDCredential) {
        id = credentials.user
        firstName = credentials.fullName?.givenName ?? ""
        lastName = credentials.fullName?.familyName ?? ""
        email = credentials.email ?? ""
    }
}

extension AppleUser: CustomDebugStringConvertible{
    var debugDescription: String{
        return """
        ID: \(id ?? "")
        First Name: \(firstName ?? "")
        Last Name: \(lastName ?? "")
        Email: \(email ?? "")
        """
    }
}

    // on ViewController
    @objc
    func didTapAppleButton(){
        if #available(iOS 13.0, *) {
            let provider = ASAuthorizationAppleIDProvider()
            let request = provider.createRequest()
            request.requestedScopes = [.fullName, .email]

            let controller = ASAuthorizationController(authorizationRequests: [request])

            controller.delegate = self
            controller.presentationContextProvider = self

            controller.performRequests()

        } else {
            // failed
        }
    }
extension ViewController: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding{

    @available(iOS 13.0, *)
    func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
        return view.window!
    }


    func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
        switch authorization.credential {
        case let credentials as ASAuthorizationAppleIDCredential:
            let user = AppleUser(credentials: credentials)
            print(user)
            /*
            Print result when Hide Email
            ID: 123215213243.e12324213.12314213 <some random Int>
            First Name: My First Name
            Last Name: My Last Name
            Email: <nil>

            Print result when normal Email used
            ID: 123215213243.e12324213.12314213 <some random Int>
            First Name: My First Name
            Last Name: My Last Name
            Email: my_email@icloud.com
            */
        default:
            // failed
        }
    }
}

Nov 15 in Mobile Development by gaurav
• 22,040 points
32 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Mobile Development

0 votes
0 answers

How to get original image when we zoom in and zoom out the image in ios

Hi i am beginner in ios and ...READ MORE

Nov 17 in Mobile Development by gaurav
• 22,040 points
14 views
0 votes
0 answers

Get Font.Weight in iOS 14

In iOS 13 and low I got ...READ MORE

4 days ago in Mobile Development by gaurav
• 22,040 points
10 views
0 votes
0 answers

How to get the user's country calling code in iOS?

I am developing an iOS app in ...READ MORE

4 days ago in Mobile Development by gaurav
• 22,040 points
7 views
0 votes
0 answers

Can I install the "app store" in an IOS simulator?

The IOS simulator in my computer doesn't ...READ MORE

3 days ago in Mobile Development by gaurav
• 22,040 points
5 views
0 votes
0 answers

Accurate timing in iOS

I am looking at the 'Metronome' sample ...READ MORE

Nov 8 in Mobile Development by gaurav
• 22,040 points
33 views
0 votes
0 answers

Swift - Find antilog for 4 digit Integer in iOS

I need to find an antilog for 5995. ...READ MORE

Nov 8 in Mobile Development by gaurav
• 22,040 points
31 views
0 votes
1 answer

Get User Group in Swift using AWS Cognito

The groups are exposed in the ID ...READ MORE

answered Nov 12, 2018 in AWS by Priyaj
• 58,100 points
951 views
0 votes
1 answer

URL Scheme for iOS Home App

I think you could try doing it ...READ MORE

answered Nov 16, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
498 views
0 votes
1 answer

iOS App : Porting Code to App

If you make a post, missing parameters ...READ MORE

answered Jan 18, 2019 in IoT (Internet of Things) by Shubham
• 13,490 points
230 views
0 votes
1 answer

swift for windows? xcode on windows? ?

Hi, @Aminegac, If you’re a little more technically ...READ MORE

answered Dec 4, 2020 in Others by Nikita
685 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP