Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get an URL from SFSafariViewController?

I am integrating fitbit login-api in iOS with Objective C and I need to get the callback URL.

I am currently using SFSafariViewController but I cannot read the URL after login. Is it possible to get the URL from SFSafariViewController ?

like image 904
Kunal Dutta Avatar asked Oct 27 '15 13:10

Kunal Dutta


People also ask

Does SFSafariViewController share cookies with Safari?

SFSafariViewController no longer shares cookies with the standalone Safari browser. Thus, a website can no longer determine that the user on SFSafariViewController is the same user on Safari, even though the view controller and the browser are open on the same device.

Is WKWebView same as Safari?

You can think of WKWebView as a stripped-down version of Safari. It is responsible to load a URL request and display the web content. WKWebView has the benefit of the Nitro JavaScript engine and offers more features. If you just need to display a specific web page, WKWebView is the best option for this scenario.

What is Safari View service?

An object that provides a visible standard interface for browsing the web. iOS 9.0+ iPadOS 9.0+ Mac Catalyst 13.1+


1 Answers

In SFSafariViewControllerDelegate you have only one method, that can help:

optional public func safariViewController(controller: SFSafariViewController, didCompleteInitialLoad didLoadSuccessfully: Bool)

But it will be called only on initial (first) url loaded. If you have redirects and wait for some url in auth process - it will not help. Then you should use UIWebView and implement UIWebViewDelegate delegate method:

optional public func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool

But don't remember to be ATS

like image 182
katleta3000 Avatar answered Sep 30 '22 12:09

katleta3000