如何从SFSafariViewController获取URL? [英] How to get an URL from SFSafariViewController?

查看:427
本文介绍了如何从SFSafariViewController获取URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Objective C在iOS中集成fitbit login-api,我需要获取回调URL。

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

我目前正在使用 SFSafariViewController 但登录后我无法读取该URL。是否可以从 SFSafariViewController 获取URL?

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

推荐答案

SFSafariViewControllerDelegate 中,您只有一种方法,可以提供帮助:

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

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

但只有在初始(第一个)url加载时才会调用它。如果你有重定向并在auth过程中等待一些网址 - 它将无济于事。
然后你应该使用 UIWebView 并实现 UIWebViewDelegate 委托方法:

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

但不记得是 ATS

这篇关于如何从SFSafariViewController获取URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆