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, 2022 in Mobile Development by gaurav
• 23,260 points
767 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, 2022 in Mobile Development by gaurav
• 23,260 points
709 views
0 votes
1 answer

Get Font.Weight in iOS 14

This is not a bug. It is ...READ MORE

answered Dec 15, 2022 in Mobile Development by gaurav
• 23,260 points
1,133 views
0 votes
1 answer

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

Import Statement : #import<CoreTelephony/CTCarrier.h> #import <CoreTelephony/CTTelephonyNetworkInfo.h> you can get country ...READ MORE

answered Dec 15, 2022 in Mobile Development by gaurav
• 23,260 points
1,226 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

Nov 23, 2022 in Mobile Development by gaurav
• 23,260 points
1,697 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

Nov 30, 2022 in Mobile Development by gaurav
• 23,260 points
425 views
0 votes
1 answer

Xcode 13.2.1 error when running on phone with iOS 15.4.1

Check /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/ for directory name 15.4 (your ...READ MORE

answered Dec 15, 2022 in Mobile Development by gaurav
• 23,260 points
1,272 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,020 points
1,566 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
1,170 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
678 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
1,813 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