Ionic Native HTTP does not work for Anroid 9 (Pie) and up?

后端 未结 2 1359
执笔经年
执笔经年 2020-12-19 05:57

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

相关标签:
2条回答
  • 2020-12-19 06:18

    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.

    In AndroidManifest.xml

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

    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>
    
    0 讨论(0)
  • 2020-12-19 06:31

    To solve that problem, you should make changes to the config.xml file.

    First thing you need to change is 'widget' tag, it should look similar to this one:

    <widget id="com.dynamicsoft.app" version="2.2.2" xmlns="http://www.w3.org/ns/widgets" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:cdv="http://cordova.apache.org/ns/1.0">
    

    After that, inside of platform where name='android', you should add this code:

    <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application android:usesCleartextTraffic="true" />
    </edit-config>
    

    After that you can run rebuild the application.

    0 讨论(0)
提交回复
热议问题