ios - React Native Webview NSURLErrorDomain 1022

标签 ios react-native

我正在尝试在 Web View 组件中显示自定义 URL(它们不是异常(exception)域中的 URL,它们是其他域,而且我并不总是知道它们的域),但似乎无法修复 Apple 的错误 1022 :无法加载资源,因为应用程序传输安全策略需要使用安全连接

我的 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>

我做错了什么?

最佳答案

尝试将您的域 key 替换为:

<key>www.akamaihd.net</key>

<key>www.faceboook.com</key> 这似乎为我解决了这个问题。另外,对于 facebook,只要在你的 webview 中路由到 https://www.facebook.com 就可以将其删除。

关于ios - React Native Webview NSURLErrorDomain 1022,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36043683/

相关文章:

ios - 在 react native 应用程序中使用提取时出错

reactjs - 获取navigation.navigate找不到变量导航

iOS:隐藏后无法显示 View

ios - Obj-C 中的委托(delegate)模式 - 我做错了吗?

javascript - 使用 React-Native 将图像上传到 Firebase

firebase - React Native 使用 .then() 中的 this.props 调用异步函数

ios - 如果变量等于使用 swift 3 的特殊数字,如何显示图像?

iOS 阻止异步回调导致 View Controller 释放后崩溃

ios - 如何使用 KYDrawerController 使用抽屉菜单更新主视图

javascript - 如何在 react 中显示 Hello World ?