Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Closed
Noitham opened this issue Sep 23, 2021 · 4 comments
Closed

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

Noitham opened this issue Sep 23, 2021 · 4 comments

Comments

@Noitham
Copy link

Noitham commented Sep 23, 2021

Hello,

I've been using this library (the former repo) 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 apport more specific information.

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 "react-native-blob-util": "0.13.15" version

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

Thanks in advance.

EDIT:

Paths were I've tested to open the .pdf from (emulator):

/data/user/0/com.{app_bundle}/cache/{....}.pdf
/storage/emulated/0/Documents/{....}.pdf

@RonRadtke
Copy link
Owner

actionViewIntent is in general still working, also with pdf. Using it in production myself.

You're using the old library? This one did not trigger a promise rejection if no app to open the pdf is installed. React-native-blob-util will reject the promise and thus give you some information.

The reason I'm writing this is, that I had the same behavior you're describing on devices which didn't have a proper app to open the file type I wanted to open. So please check if you have any app installed that can open a pdf. (Not just open but react on actionviewintent, so basically opens if you click on a pdf in e.g. a file manager)

@Noitham
Copy link
Author

Noitham commented Sep 24, 2021

Thanks for the quick response @RonRadtke.
I've made sure of it, and yes, I'm making use of the latest version (0.13.5) of the react-native-blob-util library.

Yesterday I tested on an emulator, so the option of not having an app could be there, but today I've been able to test it on an Android 11 device which has PDF apps and where we're able to open the PDF if we access it from a file manager.

The result is no feedback other than null is provided when logging the
await ReactNativeBlobUtil.android.actionViewIntent(filePath, `application/pdf`) function.

@Noitham
Copy link
Author

Noitham commented Sep 27, 2021

Issue solved!

Adding:

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

on the AndroidManifest.xml file fixed it for me 👍

@RonRadtke
Copy link
Owner

Glad to hear. Then I close the issue here

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

No branches or pull requests

2 participants