joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 771 forks source link

Unable to open PDF file on Android 11 - targetSdkVersion 30 #749

Open Noitham opened 2 years ago

Noitham commented 2 years ago

Hello,

I've been using this library for quite some time in order to open PDF files. Recently, I've updated Android's targetSdkVersion to 30, and I've noticed the actionViewIntent function is not functioning on Android 11. Using it as: android.actionViewIntent(filePath, `application/pdf`);

No error or whatsoever is thrown, so not really possible to debug.

Currently, asking for these permissions on AndroidManifest.xml:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

And have bothpreserveLegacyExternalStorage & requestLegacyExternalStorage set as true.

Using latest github:joltup/rn-fetch-blob#master version

Has somebody else faced this issue after updating? Am I missing some specific settings?

Thanks in advance.

HectorEnciso commented 2 years ago

I have the same problem, any solution?

droplessjake commented 2 years ago

I have the exact same problem also, glad I'm not alone

droplessjordan commented 2 years ago

+1

droplessjake commented 2 years ago

I believe its to do with these changes to android policies https://developer.android.com/about/versions/11/privacy/storage

Seems like we may have to find another way to write files on android now

Noitham commented 2 years ago

I have found a solution. This library here is quite unmaintained, I've found some guys that are keeping it maintained and updated:

https://github.com/RonRadtke/react-native-blob-util

Had the same issue tho with that library, but found out a solution: https://github.com/RonRadtke/react-native-blob-util/issues/66

Basically adding:

    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:mimeType="*/*" />
        </intent>
    </queries>

on the AndroidManifest.xml

Hope that makes it work for you guys, and definitely recommend switching to use the new maintained library!

droplessjake commented 2 years ago

@Noitham you absolute hero

cluth17 commented 2 years ago

@Noitham and @RonRadtke are Android 11 MVP's

retyui commented 2 years ago

This module is unmentionable ⚠️! please use fork: https://github.com/RonRadtke/react-native-blob-util

hsnMoghadasi commented 1 year ago

I have found a solution. This library here is quite unmaintained, I've found some guys that are keeping it maintained and updated:

https://github.com/RonRadtke/react-native-blob-util

Had the same issue tho with that library, but found out a solution: RonRadtke#66

Basically adding:

    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:mimeType="*/*" />
        </intent>
    </queries>

on the AndroidManifest.xml

Hope that makes it work for you guys, and definitely recommend switching to use the new maintained library!

it works for me, but still i have problem with .doc and .docs files, it wont open :/

'application/msword'