[英]Impossible to call application (URL Scheme) from UIWebView in iOS 7
A bit of an odd situation. 有点奇怪的情况。 We work with an outside partner, which exposes a webpage where their users can log in. This webpage takes a parameter called
returnURL
. 我们与外部合作伙伴合作,该合作伙伴公开了一个可供用户登录的网页。该网页采用名为
returnURL
的参数。 This returnURL
will be called upon successful login to their service and at the end of this return URL our outside partner will add a token that we can use afterwards in the application. 成功登录他们的服务后,将调用
returnURL
,在此返回URL的末尾,我们的外部合作伙伴将添加一个令牌,供以后在应用程序中使用。
Because I work in iOS, as a returnURL I am giving my application's URL scheme, so that the webpage can call it when the login is done. 因为我在iOS中工作,所以我作为应用程序的URL方案作为returnURL,以便登录后网页可以调用它。
So, it goes like this. 因此,它像这样。 Their webpage:
他们的网页:
http://www.theirwebpage.com/?param1=x¶m2=y&returnURL=myAppsName://
I show the webpage in a webview and within application:openURL:sourceApplication:annotation:
I have the code for the return, where I parse the parameters passed with myAppsName://
我在
application:openURL:sourceApplication:annotation:
以及application:openURL:sourceApplication:annotation:
显示该网页application:openURL:sourceApplication:annotation:
我有返回的代码,在这里我解析了通过myAppsName://
传递的参数
The Problem 问题
This whole process works fine on iOS 6, as the webview will call the URL scheme of the application, which will trigger application:openURL:sourceApplication:annotation:
. 整个过程在iOS 6上运行良好,因为Webview会调用应用程序的URL方案,这将触发
application:openURL:sourceApplication:annotation:
However, the application:openURL:sourceApplication:annotation:
method never gets called in iOS 7. It seems more like the webview calls itself the myAppsName://{parameters}
and then fails (for a further explanation, the UIWebView calls webView:didFailLoadWithError:
and within its NSErrorFailingURLKey
we can find the full myAppsName://extraParam1=bar&token=foo
). 但是,在iOS 7中永远不会调用
application:openURL:sourceApplication:annotation:
方法。似乎webview本身将其自身称为myAppsName://{parameters}
,然后失败(有关进一步的解释,UIWebView会调用webView:didFailLoadWithError:
并且在其NSErrorFailingURLKey
我们可以找到完整的myAppsName://extraParam1=bar&token=foo
)。
Is there a change that happened in iOS 7, where this type of call (from a UIWebView to the application itself) is no longer permitted? iOS 7是否发生了更改,不再允许这种类型的调用(从UIWebView到应用程序本身)?
Problem with xcode 5.0 . xcode 5.0出现问题。 Download the xcode version 5.0.1 .
下载xcode版本5.0.1。 Clean all the builds ~/Library/Developer/Xcode/DerivedData/~ .
清理所有版本〜/ Library / Developer / Xcode / DerivedData /〜。 Build again.
重新构建。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.