如何将NSAppTransportSecurity添加到Cordova项目

Aru*_*una 3 ios cordova ionic-framework

我正在研究离子cordova项目.该应用程序需要配置iOS 9版本的App Transport Security Exceptions.

有谁知道如何将以下配置添加到cordova项目配置文件中?(config.xml中)

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>
Run Code Online (Sandbox Code Playgroud)

问候,

Con*_*nor 7

最简单的解决方案可能是使用插件.看看cordova-plugin-transport-security

cordova plugin add cordova-plugin-transport-security --save
Run Code Online (Sandbox Code Playgroud)

您可以在其plugin.xml文件中看到它如何修改plist值.

<platform name="ios">
  <config-file target="*-Info.plist" parent="NSAppTransportSecurity">
      <dict>
          <key>NSAllowsArbitraryLoads</key>
          <true/>
      </dict>
  </config-file>
</platform>
Run Code Online (Sandbox Code Playgroud)


小智 5

参考白名单指南,应通过添加

<access origin='*' allows-arbitrary-loads-in-media='true' allows-arbitrary-loads-in-web-content='true' allows-local-networking='true' />
Run Code Online (Sandbox Code Playgroud)

到您的config.xml。