2 // AuthorizationWebViewController.swift
5 // Created by Pawel Dabrowski on 14/07/2018.
6 // Copyright © 2018 Fundacja Nowoczesna Polska. All rights reserved.
11 typealias WebView = UIWebView // WKWebView
13 class AuthorizationWebViewController: OAuthWebViewController {
16 let webView: WebView = WebView()
18 override func viewDidLoad() {
21 self.webView.frame = UIScreen.main.bounds
22 self.webView.scalesPageToFit = true
23 self.webView.delegate = self
24 self.view.addSubview(self.webView)
28 override func handle(_ url: URL) {
34 func loadAddressURL() {
35 guard let url = targetURL else {
38 let req = URLRequest(url: url)
39 self.webView.loadRequest(req)
42 open override func doHandle(_ url: URL) {
43 let completion: () -> Void = { [unowned self] in
44 self.delegate?.oauthWebViewControllerDidPresent()
46 appDelegate.mainNavigator.setRootViewController(controller: self)
51 extension AuthorizationWebViewController: UIWebViewDelegate {
52 func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
53 if let url = request.url, url.scheme == "oauth-swift" {
54 // Call here AppDelegate.sharedInstance.applicationHandleOpenURL(url) if necessary ie. if AppDelegate not configured to handle URL scheme
55 // compare the url with your own custom provided one in `authorizeWithCallbackURL`
56 self.dismissWebViewController()