我试图在web视图组件中显示自定义urls (它们不是例外域中的urls,它们是其他的,我并不总是知道它们的域),但似乎无法修复苹果的错误1022:The resource could not be loaded because the App Transport Security policy requires the use of a secure connection
我的Info.plist文件包含以下内容:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>akamaihd.net</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>facebook.com</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>needl-app.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>我做错了什么?
发布于 2016-07-23 12:48:46
尝试将您的域密钥替换为:
<key>www.akamaihd.net</key>
和
<key>www.faceboook.com</key>似乎为我解决了这个问题。此外,对于facebook,你可以删除它,只要你在你的网页视图中路由到https://www.facebook.com
发布于 2016-03-18 00:27:26
我也经历过同样的错误。您似乎无法加载不安全的网页,除非您将它们显式添加到iOS 9中的NSExceptionDomains。
您可以考虑将SFSafariViewController用于您的用例。
如果您的应用程序允许用户从互联网上的任何位置查看网站,请使用SFSafariViewController类。
SFSafariViewController目前没有随react-native一起提供。但是您可以自己创建一个custom native component。
https://stackoverflow.com/questions/36043683
复制相似问题