因此,昨晚发布的iOS新测试版SDK具有"App Transport Security",鼓励开发人员使用https而不是http.原则上,这是一个好主意,我已经在我们的临时/生产环境中使用https.但是,当iOS应用程序连接到我在笔记本电脑上运行的Web服务时,我的本地开发环境中没有设置https.
从今天早上的一些游戏中可以看出,URL加载系统即使您将其设为http URL,也会决定使用https.有谁知道如何禁用此行为 - 即使只是针对特定的URL?
我目前正在研究Xcode 7 beta 6.我正在尝试向http://mySubdomain.herokuapp.com发送"删除"请求
我收到的错误是:
App Transport Security已阻止明文HTTP(http://)资源加载,因为它不安全.可以通过应用程序的Info.plist文件配置临时例外.
进行API调用时出错:Error Domain = NSURLErrorDomain Code = -1022无法加载资源,因为App Transport Security策略要求使用安全连接.
NSLocalizedDescription =无法加载资源,因为App Transport Security策略需要使用安全连接.,NSUnderlyingError = 0x796f7ef0 {错误域= kCFErrorDomainCFNetwork代码= -1022"(null)"}}
在我的实际API调用中,我使用"https"而不是"http",这实际上适用于我的POST请求.但是DELETE请求会抛出上述错误.
我在这里看到了涉及pList文件的解决方案,但它们都没有对我有用.我在下面列出了我的尝试.
第一次尝试:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Run Code Online (Sandbox Code Playgroud)
第二次尝试:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>herokuapp.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSRequiresCertificateTransparency</key>
<false/>
</dict>
</dict>
</dict>
Run Code Online (Sandbox Code Playgroud)
最后,我甚至将所有这些临时密钥都放入:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>herokuapp.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key> …Run Code Online (Sandbox Code Playgroud) 虽然m调用我的api在ios9中出现此错误,但它在ios8中工作正常无法加载资源,因为App Transport Security策略需要使用安全连接ios9
用户WatchKit 2.0,iOS 9.0时,NSURLSession会自动发送用户代理吗?有没有办法在WatchKit应用程序中验证这一点?
这是我的组件代码..
render() {
return (
<WebView
source={{uri: 'http://qq.com'}}
style={{marginTop: 20}}
/>
);
}
Run Code Online (Sandbox Code Playgroud)
这是我的"NSAppTransportSecurity"的info.plist代码
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>qq.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
Run Code Online (Sandbox Code Playgroud)
我跑的时候
react-native run-ios
Run Code Online (Sandbox Code Playgroud)
模拟器显示错误
怎么解决?(使用RN 0.40版本)
ios ×3
ios9 ×3
nsurl ×1
nsurlsession ×1
react-native ×1
swift ×1
url ×1
user-agent ×1
watchkit ×1
xcode ×1