Ionic Native HTTP不适用于Anroid 9(Pie)及更高版本? [英] Ionic Native HTTP does not work for Anroid 9 (Pie) and up?

查看:444
本文介绍了Ionic Native HTTP不适用于Anroid 9(Pie)及更高版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个应用程序,该应用程序使用Ionic Native HTTP成功连接到我们的服务器,并使用Samsung Galaxy J7 Prime操作系统版本Marshmallow和尚未在Android Pie下运行的其他几个应用程序进行了测试.出于某种原因,当我在Android Pie下的设备上对其进行测试时,它将无法正常工作,并且我收到了CORS政策问题.有人遇到过类似的问题吗?有解决方法吗?不幸的是,不能在服务器配置中进行修改.我还阅读了一些有关代理的解决方案,但不确定如何实现.

I've created an app that connects successfully to our server using Ionic Native HTTP, testing it with Samsung Galaxy J7 Prime OS version Marshmallow and several others that were not yet under Android Pie. For some reason, when I tested it with a device under Android Pie, it won't work anymore and I'm receiving CORS policy issues. Has anybody encountered a similar issue? Is there a workaround for this? Unfortunately, modifications within the server config is not an option. I've also read some solutions about proxy but am not sure how to implement them.

版本: cordova-plugin-advanced-http:2.1.1 ionic-native/http:5.8.0

Versions: cordova-plugin-advanced-http: 2.1.1 ionic-native/http: 5.8.0

推荐答案

Android P默认情况下需要HTTPS.这意味着,如果您在应用中使用未加密的HTTP请求,则该应用将在所有低于Android P的版本中正常运行.

Android P requires HTTPS by default. What this means is that if you are using unencrypted HTTP requests in your app, the app will work fine in all lower versions than Android P.

为避免此安全异常,请尝试对应用程序代码进行以下更改.

To avoid this security exception, try below changes in your app code.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
    <application android:networkSecurityConfig="@xml/network_security_config"
                    ... >
        ...
    </application>
</manifest>

并在res/xml中添加名为network_security_config.xml

and in res/xml add file named : 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>

这篇关于Ionic Native HTTP不适用于Anroid 9(Pie)及更高版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆