Cordova如何支持Android 7.0引入的Network Security Config? [英] How Cordova support Network Security Config introduced by Android 7.0?
问题描述
Android 7.0引入了网络安全配置以支持使用自定义CA,但是Cordova如何支持它?我从Cordova的文档中找不到任何提示。
Android 7.0 intorduced Network Security Config to support use custom CAs, but how Cordova support that? I can not find any hint from docs of Cordova.
推荐答案
您可以通过添加 edit来实现-config
标记到 config.xml
中的Android平台,这由Cordova Android插件v7.0支持。
You can achieve this by adding the edit-config
tag to the Android platform in your config.xml
, this is supported by Cordova Android Plugin v7.0.
您将需要使用 Google 。
Cordova中的下一个 config.xml
您可以使用 edit-config
标记将 networkSecurityConfig
属性添加到Application标记。然后,您只需将网络安全配置文件作为应用程序的资源复制到 res / xml
目录。
Next in the Cordova config.xml
you can use the edit-config
tag to add the networkSecurityConfig
attribute to the Application tag. Then you just need to copy the Network Security Config file as a resource for your application to the res/xml
directory.
这是一个在您的应用程序config.xml中看起来如何的示例。
Here is an example of how this might look in your applications config.xml
...
<platform name="android">
<edit-config xmlns:android="http://schemas.android.com/apk/res/android" file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:networkSecurityConfig="@xml/network_security_config" />
</edit-config>
<resource-file src="network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
</platform>
...
这篇关于Cordova如何支持Android 7.0引入的Network Security Config?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!