Sign in With Apple works, but blocks app afterwards

This is a continuation of

https://developer.apple.com/forums/thread/760861

Still a mixed Qt/C++/ObjC app, developed with Qt Creator.

The gist ist that I can call Sign in With Apple and authorise, but once the Authorisation Window/Panel goes away, the app is blocked.

PBSigninWithApple:: PBSigninWithApple()
{
myImpl = [[PBSigninWithApple alloc] initWithOwner:this];
}

- (id)initWithOwner:(PBSigninWithApple *) owner {
self = [super init];
myOwnerSIWA = owner;

ASAuthorizationAppleIDProvider *appleIDProvider = [ASAuthorizationAppleIDProvider new];
ASAuthorizationAppleIDRequest *request = appleIDProvider.createRequest;
request.requestedScopes = @[ASAuthorizationScopeFullName, ASAuthorizationScopeEmail];


ASAuthorizationController *controller = [[ASAuthorizationController alloc] initWithAuthorizationRequests:@[request]];
controller.presentationContextProvider = self;
controller.delegate = self;

[controller performRequests];

return self;
}

The code example above is obviously reduced, but the real things works. I get the Sign in With Apple window and can authorise by TouchId. The didCompleteWithAuthorization and didCompleteWithError methods also work, emitting the the idendityToken to the calling superclass works, the authorisation window goes away - but not really. The calling QT app is semi-blocked. I can close windows ny using the Escape key, but any clicking just gives the dreaded beep and nothing happens. So I assume that we didn‘t tear down everything and that the anchor or whatever still has to focus.

- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization  API_AVAILABLE(macos(10.15)) {

    if ([authorization.credential isKindOfClass:[ASAuthorizationAppleIDCredential class]]) {

    ASAuthorizationAppleIDCredential *appleIDCredential = authorization.credential;
    NSString *user = appleIDCredential.user;
    NSData  *identityToken = appleIDCredential.identityToken;
    NSData  *authorizationCode = appleIDCredential.authorizationCode;

    emit myOwnerSIWA->accessCodeReceived(identityToken);
    } 


[[NSNotificationCenter defaultCenter]
    removeObserver:self
              name:ASAuthorizationAppleIDProviderCredentialRevokedNotification
            object:nil];

    [myAnker close];
    [self release];
}


- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(ASAuthorization *)authorization  API_AVAILABLE(macos(10.15)) {
emit myOwnerSIWA->accessCodeReceived(QString(""));
[[NSNotificationCenter defaultCenter]
    removeObserver:self name:ASAuthorizationAppleIDProviderCredentialRevokedNotification
            object:nil];
}


-(ASPresentationAnchor)presentationAnchorForAuthorizationController:(ASAuthorizationController  *)controller API_AVAILABLE(macos(10.15)) {

    NSRect frame = NSMakeRect(30, 30, 230, 230);
    NSUInteger windowStyle = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable | NSWindowStyleMaskFullSizeContentView;

    NSWindow* window  = [[[NSWindow alloc] initWithContentRect:frame
                                                 styleMask:windowStyle
                                                   backing:NSBackingStoreBuffered
                                                     defer:NO] autorelease];
    window.minSize = CGSizeMake(200, 100);
    window.releasedWhenClosed = TRUE;
    myAnker = window;
    return window;
}
Answered by DTS Engineer in 805187022

Hi,

The presentation anchor is expected to be an active window of the active scene representing the authentication flow of your app. In the code snippet above, you have created a new window for this auth flow presentation, but the window is not actively associated with the scene, nor is it key. The behavior you are reporting is expected with the code implemented above.

Please see the following documentation to learn more:

You can use the existing main (or key) window of your app for this presentation anchor, or create a new one—but a new window should also be made key and active.

Cheers,

Paris X Pinkney |  WWDR | DTS Engineer

Hi,

The presentation anchor is expected to be an active window of the active scene representing the authentication flow of your app. In the code snippet above, you have created a new window for this auth flow presentation, but the window is not actively associated with the scene, nor is it key. The behavior you are reporting is expected with the code implemented above.

Please see the following documentation to learn more:

You can use the existing main (or key) window of your app for this presentation anchor, or create a new one—but a new window should also be made key and active.

Cheers,

Paris X Pinkney |  WWDR | DTS Engineer

Sign in With Apple works, but blocks app afterwards
 
 
Q