Skip to content

Commit 1d7f49e

Browse files
committed
Use asynchronous execution for safariViewController
This prevents from updating an animated UI component's state from a background thread and fixes related app crashes on iOS
1 parent 2a1fb1b commit 1d7f49e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ios/OAuthManager/OAuthManager.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ + (BOOL)setupOAuthHandler:(UIApplication *)application
8888
[authPlatform setURLOpener: ^void(NSURL *URL, DCTAuthPlatformCompletion completion) {
8989
// [sharedManager setPendingAuthentication:YES];
9090
if ([SFSafariViewController class] != nil) {
91-
safariViewController = [[SFSafariViewController alloc] initWithURL:URL];
92-
UIViewController *viewController = application.keyWindow.rootViewController;
93-
[viewController presentViewController:safariViewController animated:YES completion: nil];
91+
dispatch_async(dispatch_get_main_queue(), ^{
92+
safariViewController = [[SFSafariViewController alloc] initWithURL:URL];
93+
UIViewController *viewController = application.keyWindow.rootViewController;
94+
[viewController presentViewController:safariViewController animated:YES completion: nil];
95+
});
9496
} else {
9597
[application openURL:URL];
9698
}

0 commit comments

Comments
 (0)