ConnectController
@objcMembers
@MainActor
public class ConnectController : UIViewController, WKNavigationDelegate, WKUIDelegate
A view controller responsible for:
- Initializing and presenting the WKWebView.
- Detecting redirects back to the application (via
webView(_:decidePolicyFor:decisionHandler:)). - Invoking the callback closure when the application redirect is encountered.
- Opening new-window (
target="_blank") links outside the web view.
-
Undocumented
Declaration
Swift
@MainActor public var webView: WKWebView! -
Initializes the ConnectController.
Declaration
Swift
@MainActor public init(authUrl: URL, redirectUriHost: String?, handleCallback: @escaping (URL) -> Void, onCompleteResult: @escaping (CompleteParams) -> Void = { _ in })Parameters
authUrlThe Connect URL to open in the WKWebView.
redirectUriHostHost of the redirect URI that was passed to SmartcarAuth.
nilwhen the flow was configured without a redirect URI (responseType == "none").handleCallbackCallback function that is invoked upon redirect back to the application.
onCompleteResultCallback function that is invoked when Connect signals flow completion via the
completeRPC instead of a redirect. -
Undocumented
Declaration
Swift
@MainActor public override func viewDidLoad() -
WKNavigationDelegate method: listens for navigation changes. If the navigation is to the redirect URI (matching
redirectUriHost), call thehandleCallbackand remove the webView from the view. If the navigation is a new-window request (target="_blank"), open it externally and leave the Connect page in place.Declaration
Swift
@MainActor public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) -
WKUIDelegate method: called when the page asks for a new window that didn’t go through
decidePolicyForfirst (e.g. a user-initiatedwindow.open()). There’s no second screen to show it in, so open the URL externally and decline to create a web view.Declaration
Swift
@MainActor public func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? -
Undocumented
Declaration
Swift
@MainActor public override func viewDidDisappear(_ animated: Bool)
View on GitHub