Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sign in with Apple - Different behaviour Simulator VS iPhone

I'm trying to setup Sign-in with Apple with Xcode (Beta 11.0 beta 6).

Works great on simulator, but when I run it on my iPhone (iOS 13.1), I don't get the same display.

On Simulator:

On Simulator

On iPhone:

On iPhone

This is how I call my "Sign in with Apple":

- (IBAction)signInWithApple:(id)sender {
    if (@available(iOS 13.0, *)) {
        ASAuthorizationAppleIDProvider *appleIDProvider = [[ASAuthorizationAppleIDProvider alloc] init];
        ASAuthorizationAppleIDRequest *request = [appleIDProvider createRequest];
        request.requestedScopes = @[ASAuthorizationScopeFullName,ASAuthorizationScopeEmail];
        ASAuthorizationController *authorizationController = [[ASAuthorizationController alloc] initWithAuthorizationRequests:@[request]];
        authorizationController.delegate = self;
        authorizationController.presentationContextProvider = self;
        [authorizationController performRequests];
    } else {
        // Fallback on earlier versions
    }
}

Based on my debug I know that in both cases the code is executed and the email + fullname scope are set in the authorizationController.

I expect in both cases to see the Sign in with apple and to be ask about my fullname and if I wanna Hide My email...

But it only happen on simulator. On iPhone I just "continue", get my face recognize... And that's it.

In both case this is called after:

-(void)authorizationController:(ASAuthorizationController *)controller
  didCompleteWithAuthorization:(ASAuthorization *)authorization  API_AVAILABLE(ios(13.0)){

    ASAuthorizationAppleIDCredential *appleIDCredential = authorization.credential;
...

But in case of Simulator I'm able to get values for

"appleIDCredential.identityToken"
"appleIDCredential.email"
"appleIDCredential.fullName"

While on my iPhone I'm only able to get values for

"appleIDCredential.identityToken"

Thank you for your help ! :)

PS: In both cases I tried to connect with the same Apple Account, so I tried to look about apple configuration but I'm not sure what's wrong if it's the problem.

like image 896
royraider Avatar asked Aug 29 '19 16:08

royraider


People also ask

Does Apple sign in work in simulator?

I have no idea why, I just know that the exact same code works perfectly with Xcode-11 ios-13 simulator. Now it just hangs during a verification and a log says "connection to background transfer daemon invalidated".

Is Sign in with Apple better?

Sign in with Apple won't track or profile you as you use your favorite apps and websites. Apple retains only the information that's needed to make sure you can sign in and manage your account. Security is built in to Sign in with Apple with two-factor authentication.

How do I pair Apple Watch simulator with iPhone?

How do I get the watch simulator to appear when I select an iPhone simulator in Device? In the Devices window under Simulators, select an iPhone 5 and later simulator. Under the Paired Watches table, click the Add button (+).

How do I sign out of Apple ID on simulator?

Show activity on this post. To logout from iOS simulator using xCode 6.3. 1, go to Setting -> Safari -> Clear History and Website Data.


1 Answers

It seems on Simulator you see sign-up flow (first time user experience) and on the device you've already passed through sign-up and now you see log-in flow (returning user experience). I'm not sure why doesn't simulator display the log-in flow, but it works the same way for me as well.

According to documentation and this thread you won't get user info (email and full name) on completion of the log-in flow:

Ensure that your app relays the credentials and user information to your app servers. The API collects this information and shares it with your app the first time the user logs in to the app using Sign in with Apple. If the user then uses Sign in with Apple on another device, the API doesn't ask for the user’s name or email again. It collects the information again only if the user stops using Sign in with Apple and later reconnects to your app.

Because the user’s information isn’t shared with your app in any subsequent API calls, your app should store it locally, immediately after you receive it from the API response. In case of subsequent failures in your process or network, you can read the information from local storage and try processing it again.

There is a way to return to the sign-up flow on you device by revoking usage of Apple ID by your application. To do it you can go to device Settings → Passwords & Accounts → iCloud → Password & Security → Apps Using Your Apple ID → [NameOfYourApp] App → Stop Using Apple ID → Stop Using.

You also can visit your Apple ID App Security page to do it. It should look like this:

Apple ID App Security page

I took the image and some hints from What the Heck is Sign In with Apple?

like image 107
Eugene Berdnikov Avatar answered Oct 18 '22 23:10

Eugene Berdnikov