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

PDFs are not downloaded, but sharing dialog is opened instead #10

Open
augustosamame opened this issue Apr 12, 2021 · 2 comments
Open

Comments

@augustosamame
Copy link

Hi. Thanks for the great library.
Tried to download a PDF, but it's not downloaded at all in iOS. The native iOS sharing dialog is opened instead.

@augustosamame
Copy link
Author

I see this is as designed:

 // if this is not an image file on iOS
        // we use "Sharing" library and quit early (let iOS handle it)
        if (ios &&
            imageFileExts.every((x) => !downloadedFile.uri.toLocaleLowerCase().endsWith(x))) {
            const UTI = "public.item";
            const shareResult = await Sharing.shareAsync(downloadedFile.uri, {
                UTI,
            });
            return true;

Is there a particular limitation for PDF files in iOS? iOS can't handle them even when downloaded into Documents or Downloads folder? I'd be willing to give a shot with a PR if you point me in the right direction.

@kathawala
Copy link
Owner

kathawala commented Apr 24, 2021

@augustosamame

From looking around, I believe this is a limitation of iOS. You are meant to provide user's with options on what they want to do with a document instead of forcing a download to a folder. Here's an example answer from Stack Overflow:

This is an example of a way to save a document. You can't force it to be downloaded and show up in their Files app. You have to present a UIActivityViewController that shows options on what they can do with that document.

What can be done is that you can add the following keys to your info.plist: "UISupportsDocumentBrowser", "UIFileSharingEnabled", "LSSupportsOpeningDocumentsInPlace". and then any files you download through the app to the app's internal storage will be exposed to the user's My Files app. You will still not be able to directly download any files directly to the Downloads / Documents folders in My Files, but you could download a file to, say, MyApp/Documents/ which would be accessible in the My Files app.

Hope that makes sense. This library can't control people's info.plist but we could make it possible to disable the Sharing dialog (if you are on iOS then the Sharing dialog wouldn't open, your file would be downloaded to MyApp/Documents/ in the My Files app, but you would be responsible for setting info.plist to expose the MyApp directory to users). I could add a configuration option to enable this method of downloading files for those who prefer it to the Sharing dialog.

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