We are developing an application for iOS 8.0 and higher. This application requires authentication (or what the user registers for it). On the website, we use html forms to register and login users. These forms are responsive. The user can also click โLog in using the Facebook buttonโ to log in with FB credentials. This button is implemented using the FB SDK for Javascript (v2.4)
Thus, we do not want to implement our own screen in our iOS application for registration and registration, but we rather implemented a view controller with a WKWebView element to handle this view.
However, we noted that when users click on the โLog in using Facebook buttonโ button, nothing happens. The typical pop-up window that FB opens to ask the user to log in and grant access permissions never appears.
This is how we initialize WKWebView :
class LoginViewController: UIViewController, WKNavigationDelegate, WKUIDelegate { var webView: WKWebView @IBOutlet weak var cancelButton: UIButton! override func viewDidLoad() { super.viewDidLoad() view.addSubview(webView) webView.setTranslatesAutoresizingMaskIntoConstraints(false) let height = NSLayoutConstraint(item: webView, attribute: .Height, relatedBy: .Equal, toItem: view, attribute: .Height, multiplier: 1, constant: 0) let width = NSLayoutConstraint(item: webView, attribute: .Width, relatedBy: .Equal, toItem: view, attribute: .Width, multiplier: 1, constant: 0) view.addConstraints([height, width]) loadDefaultUrl() } required init(coder aDecoder: NSCoder){ let config = WKWebViewConfiguration() config.preferences.javaScriptCanOpenWindowsAutomatically = true self.webView = WKWebView(frame: CGRectZero, configuration: config) super.init(coder: aDecoder) webView.navigationDelegate = self webView.UIDelegate = self }
Would thank all pointers on how to get the FB login button to work in WKWebView (or, if possible, within UIWebView ).
source share