Transport security has blocked a cleartext HTTP(传输安全已阻止明文 HTTP)
问题描述
根据以下错误消息,我需要在 info.plist 中进行什么设置才能启用 HTTP 模式?
What setting do I need to put in my info.plist to enable HTTP mode as per the following error message?
传输安全已阻止明文 HTTP (http://) 资源加载,因为它不安全.可以通过以下方式配置临时异常您应用的 Info.plist 文件.
Transport security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
假设我的域是 example.com.
推荐答案
如果你使用的是 Xcode 8.0+ 和 Swift 2.2+ 甚至 Objective C:
If you are using Xcode 8.0+ and Swift 2.2+ or even Objective C:
如果你想允许 HTTP 连接到任何站点,你可以使用这个键:
If you want to allow HTTP connections to any site, you can use this keys:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
如果您知道要连接到哪些域,请添加:
If you know which domains you will connect to add:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
这篇关于传输安全已阻止明文 HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:传输安全已阻止明文 HTTP
基础教程推荐
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
