简体   繁体   English

iOS 应用传输安全

[英]iOS App Transport Security

I have listings on an app that contain many different URL's;我在一个包含许多不同 URL 的应用程序上有列表; therefore, I've set my info.plist to ...因此,我已将 info.plist 设置为...

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

On the simulator everything works.在模拟器上一切正常。 On my testing devices it won't work.在我的测试设备上它不起作用。

Error is...错误是...

2015-11-10 18:58:05.159 MPSTApp[520:169178] -canOpenURL: failed for URL: "https:/www.facebook.com/prontosantateresa -- file:///" - error: "This app is not allowed to query for scheme file" 2015-11-10 18:58:05.159 MPSTApp[520:169178] -canOpenURL:URL 失败:“https://www.facebook.com/prontosantateresa -- file:///” - 错误:“这个应用程序不是允许查询方案文件"

The code calling the url link is such -调用 url 链接的代码是这样的 -

var anchorLink: String?

func loadWebPage(){
    let requestURL = NSURL(string: anchorLink!)
    let request = NSURLRequest(URL: requestURL!)
    webView.loadRequest(request)
}

You've got a typo in your URL.您的 URL 中存在拼写错误。 Change:改变:

https:/facebook.com

To:到:

https://facebook.com

Also, you should change LSAllowsArbitraryLoads back to the default value, since that's best for most apps.此外,您应该将LSAllowsArbitraryLoads更改回默认值,因为这最适合大多数应用程序。

For iOS9, you must add something to the plist file:对于 iOS9,您必须在 plist 文件中添加一些内容:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fbapi20130214</string>
    <string>fbapi20130410</string>
    <string>fbapi20130702</string>
    <string>fbapi20131010</string>
    <string>fbapi20131219</string>    
    <string>fbapi20140410</string>
    <string>fbapi20140116</string>
    <string>fbapi20150313</string>
    <string>fbapi20150629</string>
    <string>fbauth</string>
    <string>fbauth2</string>
    <string>fb-messenger-api20140430</string>
</array>

For more: Preparing Your Apps for iOS9更多信息:为 iOS9 准备你的应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM