react native - How to add a prompt option to the user while choosing an app to open the file with?

Viewed 130

I use the react-native-file-viewer directory I want to know how to add the option to my code to Prompt the user to choose an app to open the file with .. does anyone know how to do it ?

import FileViewer from 'react-native-file-viewer';
import RNFS from 'react-native-fs';

const file = 'actions-for-db.xls';
        // feel free to change main path according to your requirements
        const dest = `${RNFS.DocumentDirectoryPath}/${file}`;
        RNFS.copyFileAssets(file, dest)
            .then(() => {
                FileViewer.open(dest)
                    .then(() => { })
                    .catch(() => { })
                console.log(dest);
            })
            .then(() => {
                // success
                console.log('success');
            })
            .catch(error => {
                /* */
                console.log('error');
            });
1 Answers

ok I found the solution for that.. you should have more than one app that open your file, only than you can get the prompt options .

Related