Opening external links in webkit

Hi everyone!

Im really new to programming and im trying to build my first "app". It is just app what opens webpage (company store) and it works fine. But in signin page there is links to login with facebook account and those links doesnt work. I have googled my *** off and havent found solution. Maybe you guys could help me figure out what needs to be done to get it working? My viewcontroller.swift looks like this:


import UIKit

import WebKit

class ViewController: UIViewController, WKNavigationDelegate {

var webView: WKWebView?

override func prefersStatusBarHidden() -> Bool {

return true

}

/ Start the network activity indicator when the web view is loading */

func webView(webView: WKWebView,

didStartProvisionalNavigation navigation: WKNavigation){

UIApplication.sharedApplication().networkActivityIndicatorVisible = true

}

/ Stop the network activity indicator when the loading finishes */

func webView(webView: WKWebView,

didFinishNavigation navigation: WKNavigation){

UIApplication.sharedApplication().networkActivityIndicatorVisible = false

}

override func viewDidLoad() {

super.viewDidLoad()

/ Create our preferences on how the web page should be loaded */

let preferences = WKPreferences()

preferences.javaScriptEnabled = true

/ Create a configuration for our preferences */

let configuration = WKWebViewConfiguration()

configuration.preferences = preferences

/ Now instantiate the web view */

webView = WKWebView(frame: view.bounds, configuration: configuration)

if let theWebView = webView{

/ Load a web page into our web view */

let url = NSURL(string: "https://www.companypage.com")

let urlRequest = NSURLRequest(URL: url!)

theWebView.loadRequest(urlRequest)

theWebView.navigationDelegate = self

view.addSubview(theWebView)

}

}

}

I tried with normal safari browser and clicking facebook button opens new tab where i can type my login credentials. So I would need to allow opening new window and when im done I could press "Done" and that would close window and return original page. I have tried to implement SFSafariViewController without success.

Opening external links in webkit
 
 
Q