From 38ba3b021c69079e319d248f4fec156e10d8dfc1 Mon Sep 17 00:00:00 2001 From: "Eric C. Johnson" Date: Fri, 20 Sep 2024 12:35:06 -0600 Subject: [PATCH] @W-16362973: [iOS] Add QR Code Login Support in MSDK (Introduce `isQrCodeLoginEnabled`. Functional P.O.C.) --- .../Classes/Common/SalesforceSDKManager.h | 3 +++ .../Classes/Login/SFLoginViewController+QrCodeLogin.swift | 7 ++++--- .../SalesforceSDKCore/Classes/OAuth/SFOAuthCoordinator.m | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Common/SalesforceSDKManager.h b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Common/SalesforceSDKManager.h index 743ee41d27..eaeb63071f 100644 --- a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Common/SalesforceSDKManager.h +++ b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Common/SalesforceSDKManager.h @@ -225,6 +225,9 @@ NS_SWIFT_NAME(SalesforceManager) */ @property (nonatomic, assign) BOOL isLoginWebviewInspectable; +/*** Indicates if login via QR Code and UI bridge API is enabled */ +@property (nonatomic, assign) BOOL isQrCodeLoginEnabled; + /** The type of cache used for the shared URL cache, defaults to kSFURLCacheTypeEncrypted. */ @property (nonatomic, assign) SFURLCacheType URLCacheType; diff --git a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Login/SFLoginViewController+QrCodeLogin.swift b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Login/SFLoginViewController+QrCodeLogin.swift index aac233386f..afebf321ec 100644 --- a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Login/SFLoginViewController+QrCodeLogin.swift +++ b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Login/SFLoginViewController+QrCodeLogin.swift @@ -51,11 +51,12 @@ public extension SalesforceLoginViewController { ) { print("Login With Frontdoor Bridge URL: '\(frontdoorBridgeUrlString)'/'\(String(describing: pkceCodeVerifier))'.") - // TODO: W-16171402: Integrate With Existing Login Logic And Resolve Use Of PKCE Code Verifier. ECJ20240912 - guard let frontdoorBridgeUrl = URL(string: frontdoorBridgeUrlString) else { return } guard let webView = oauthView as? WKWebView else { return } - webView.load(URLRequest(url: frontdoorBridgeUrl)) + + DispatchQueue.main.async { + webView.load(URLRequest(url: frontdoorBridgeUrl)) + } } // MARK: QR Code Login Via UI Bridge API Private Implementation diff --git a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/OAuth/SFOAuthCoordinator.m b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/OAuth/SFOAuthCoordinator.m index 00d317a99f..ea01b90791 100644 --- a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/OAuth/SFOAuthCoordinator.m +++ b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/OAuth/SFOAuthCoordinator.m @@ -791,7 +791,7 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati NSURL *url = navigationAction.request.URL; NSString *requestUrl = [url absoluteString]; if ([self isRedirectURL:requestUrl]) { - if ([[SalesforceSDKManager sharedManager] useWebServerAuthentication]) { + if ([[SalesforceSDKManager sharedManager] useWebServerAuthentication] && ![[SalesforceSDKManager sharedManager] isQrCodeLoginEnabled]) { [self handleWebServerResponse:url]; } else { [self handleUserAgentResponse:url];