Pet*_*ete 3 mobile android cordova ionic-framework ionic4
我创建了一个应用程序,该应用程序使用Ionic Native HTTP成功连接到我们的服务器,并使用Samsung Galaxy J7 Prime OS版本的棉花糖和尚不在Android Pie下的其他几个软件对其进行了测试。出于某种原因,当我在Android Pie下的设备上对其进行测试时,它将无法再使用,并且我收到了CORS政策问题。有人遇到过类似的问题吗?有没有解决方法?不幸的是,不能在服务器配置中进行修改。我还阅读了一些有关代理的解决方案,但不确定如何实现它们。
版本:cordova-plugin-advanced-http:2.1.1 ionic-native / http:5.8.0
Android P默认情况下需要HTTPS。这意味着,如果您在应用中使用未加密的HTTP请求,则该应用在所有低于Android P的版本中均可正常运行。
为避免此安全异常,请尝试以下更改应用程序代码。
在AndroidManifest.xml中
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="@xml/network_security_config"
... >
...
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
并在res / xml中添加名为的文件: network_security_config.xml
network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
// Add host of your download URL in below line.
// ie. if url is "https://www.google.com/search?source=...."
// then just add "www.google.com"
<domain includeSubdomains="true">www.google.com</domain>
</domain-config>
</network-security-config>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1881 次 |
| 最近记录: |