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 772 forks source link

When choose downloaded file (PDF) in Files and click then it opens my app [IOS] #656

Open nightdaydream opened 3 years ago

nightdaydream commented 3 years ago

Hi! How to set that we can open downloaded file in Files app? It was saved in Files app in the my app directory, and when you tapped on file it opened in my app. It is not correct. I need to open it in Browser (Files on ios). Can anyone help and say please, how to save file in Files and have opportunity to open it not in my app? using versions: "rn-fetch-blob": "0.12.0", "react-native": "0.62.2" I found some flags for Info.plist and use it, and use different combinations of these flags, but they don't work. Maybe I should use other flags, which give opportunity to open File in Files app, like simple document (it is a simple pdf).

<key>UISupportsDocumentBrowser</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>

My code:

....
const base64Data = response.data;
const fileLocation = `${RNFetchBlob.fs.dirs.DocumentDir}/${filename}`;
RNFetchBlob.fs.writeFile(fileLocation, base64Data, 'base64').then((res: any) => {
    if (isIOS) {
        FileViewer.open(fileLocation);
    } });