I use WKWebView to load my webpage. When user click a button in webpage, my webpage will open a custom schema URL (e.g. asfle://download?media_id=1). And I use KVO to obser
I found the solution. Instead of using KVO, use delegate to detect opening URL.
override func viewDidLoad() {
super.viewDidLoad()
webView.navigationDelegate = self
}
func webView(webView: WKWebView, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void) {
print("url:\(navigationAction.request.URL)")
decisionHandler(.Allow)
}