我想在我的应用程序中打开一个url并登录。在那之后,它会重定向到某个地方,它会给我一个回应(200或500)。,我想得到你的回应。
有可能吗?我已经看到了几种选择: webview、使用SafariServices甚至SFAuthenticationSession的Safariview控制器(但它是不推荐的,新的是iOS 12.)
你有什么建议吗?
最亲切的问候!!
发布于 2018-08-01 09:12:03
您可以使用WKWebView及其委托函数来存档这种行为。
发布于 2018-08-01 09:28:02
如果您正在使用UIWebview,则使用JavaScript技术在该web视图中加载数据。就像这样
public func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if let requestUrl = request.url, requestUrl.absoluteString.hasPrefix("check with your url prefix") {
let absoluteStr = requestUrl.absoluteString.replacingOccurrences(of: "use to make url", with: "")
if let absoluteUrl = URL(string: absoluteStr) {
// do what you want with your url now.
}
}
}UIWebView的完成和错误委托
public func webViewDidFinishLoad(_ webView: UIWebView) {
if !webView.isLoading {
//webview loading complete
}
}
public func webView(_ webView: UIWebView, didFailLoadWithError error: Error)
{
// Call failure callback except for the error of WebKitErrorDomain
if ((error as NSError).domain != webKitErrorDomain) {
// delegate error where do you want.
}
}https://stackoverflow.com/questions/51628728
复制相似问题