Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Can't download file with http domain url in android 9 pie #351

Closed
ganesh98a opened this issue Apr 25, 2019 · 7 comments
Closed

Can't download file with http domain url in android 9 pie #351

ganesh98a opened this issue Apr 25, 2019 · 7 comments

Comments

@ganesh98a
Copy link

ganesh98a commented Apr 25, 2019

Hi ! i am using rnfetchblob to download the file using get method through HTTP domain url. it's not working in android 9 pie version only. also i have tried and cross check with android behavior changes of version update

here my code

const { config, fs } = RNFetchBlob;
 let options = {
        
        addAndroidDownloads: {
          fileCache: true,
          path: PictureDir + '/RFIs' + Math.floor(date.getTime() + date.getSeconds() / 2) + '.pdf',
          useDownloadManager: true,
          notification: true,
          mediaScannable: true,
          path: PictureDir + '/RFIs' + Math.floor(date.getTime() + date.getSeconds() / 2) + '.pdf',
          description: 'Downloading.',
          mime: 'application/pdf'
        }
      };
pdfData='http://...';
config(options).fetch('GET', pdfData).then((res) => {
});

Behavior changes are applied
Manifest file *****

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.fulcrum">
 <application 
        xmlns:tools="http://schemas.android.com/tools"
        android:name=".MainApplication"
        android:allowBackup="true"
         android:usesCleartextTraffic="true"
        android:networkSecurityConfig="@xml/network_security_config"
        >
        <uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
</manifest>

network_security_config.xml*****

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
</network-security-config>

React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz
Memory: 1.39 GB / 7.84 GB
Binaries:
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
React-native version
"react": "16.8.3",
"react-native": "0.59.5"
"rn-fetch-blob": "^0.10.13"

Note: it's working with HTTPS domain url with above code & environment setup

Will you pls get me out to solve this.

Thanks

@ganesh98a ganesh98a changed the title Cann't download file with http domain url in android 9 pie Can't download file with http domain url in android 9 pie Apr 25, 2019
@jpodpro
Copy link

jpodpro commented Jun 23, 2019

it looks like pie disables http traffic by default. there's a manifest setting that appears to allow it. read this for more info:
facebook/react-native#24627

@mayankgarg056
Copy link

Same problem with me

@tatva-hiral
Copy link

Same issue facing, android 9 file not downloaded

@ganesh98a
Copy link
Author

ganesh98a commented Sep 20, 2019

@tatva-hiral @mayankgarg056 Pls check your phone system update is "Up to Date". i haven't facing that issue now

@ganesh98a ganesh98a reopened this Sep 20, 2019
@tatva-hiral
Copy link

@ganesh98a It's not working on specific devices, that is android 9-oxygen OS(oneplus) or after updating android that shows me Android security patch level for other devices.

@ganesh98a
Copy link
Author

@tatva-hiral pls make sure you have added those line below.

<application
android:usesCleartextTraffic="true"
>
<uses-library android:name="org.apache.http.legacy" android:required="false"/>

After adding that. i have run the app and resetarted my mobile. it has worked

@NSR88
Copy link

NSR88 commented Sep 29, 2020

@ganesh98a I tried doing the same, but still not working for me on Android Pie (9). What else is missing?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants