Ref : https://stackoverflow.com/questions/31988121/facebook-login-button-does-not-work-within-wkwebview
func webView(webView: WKWebView, createWebViewWithConfiguration configuration: WKWebViewConfiguration, forNavigationAction navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
// A nil targetFrame means a new window (from Apple's doc)
if (navigationAction.targetFrame == nil) {
// Let's create a new webview on the fly with the provided configuration,
// set us as the UI delegate and return the handle to the parent webview
let popup = WKWebView(frame: self.view.frame, configuration: configuration)
popup.UIDelegate = self
self.view.addSubview(popup)
return popup
}
return nil;
}
ow that this is done, the new request will automatically be loaded in the "popup"
WKWebView
that was just created. The next step is to make sure to close it once the flow is done. Since we registered self
as the popup.UIDelegate
, we can remove the view when it will be closed by the external authentication flow:func webViewDidClose(webView: WKWebView) {
// Popup window is closed, we remove it
webView.removeFromSuperview()
}
沒有留言:
張貼留言