From 1d7f49e7ebc4dae01259a23c4b244c1447c343ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0imonfy?= Date: Wed, 3 Jan 2018 14:18:57 +0100 Subject: [PATCH] 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 --- ios/OAuthManager/OAuthManager.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ios/OAuthManager/OAuthManager.m b/ios/OAuthManager/OAuthManager.m index a9451bc..f490ecf 100644 --- a/ios/OAuthManager/OAuthManager.m +++ b/ios/OAuthManager/OAuthManager.m @@ -88,9 +88,11 @@ + (BOOL)setupOAuthHandler:(UIApplication *)application [authPlatform setURLOpener: ^void(NSURL *URL, DCTAuthPlatformCompletion completion) { // [sharedManager setPendingAuthentication:YES]; if ([SFSafariViewController class] != nil) { - safariViewController = [[SFSafariViewController alloc] initWithURL:URL]; - UIViewController *viewController = application.keyWindow.rootViewController; - [viewController presentViewController:safariViewController animated:YES completion: nil]; + dispatch_async(dispatch_get_main_queue(), ^{ + safariViewController = [[SFSafariViewController alloc] initWithURL:URL]; + UIViewController *viewController = application.keyWindow.rootViewController; + [viewController presentViewController:safariViewController animated:YES completion: nil]; + }); } else { [application openURL:URL]; }