How to add the option to my code to Prompt the user to choose an app to open the file with
roei133 opened this issue · 2 comments
roei133 commented
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 ..
someone 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');
});
vinzscam commented
Hi,
as mentioned in the documentation, in your snippet replace
FileViewer.open(dest)
with
FileViewer.open(dest, { showOpenWithDialog: true })
Keep in mind that this functionality is only available in Android, as mentioned in the documentation.
ArkanRomanPango commented
@vinzscam how is it possible to invoke this dialog on ios? maybe some another package? thank you