wkh237 / react-native-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.61k stars 1.6k forks source link

RNFetchBlob.ios.previewDocument and .epub files #337

Open eddnav opened 7 years ago

eddnav commented 7 years ago

It doesn't seem like previewDocument can open .epub with the default app (I think normally this would be iBooks), is there something that could be done for this? I'm using react-native-fetch-blob 0.10.4 and RN 0.42.3.

I tried using the optional scheme param to no avail:

    const ios = RNFetchBlob.ios;
    const dirs = RNFetchBlob.fs.dirs;

    RNFetchBlob
      .config({
        scheme: 'itms-books',
        path: dirs.DocumentDir + '/' + title + '.epub'
      })
      .fetch('GET', 'https://www.gutenberg.org/ebooks/54563.epub', {
        // Headers here
      })
      .then((res) => {
        console.log('The file saved to ', res.path());
        ios.previewDocument(res.path()).catch((err) => Alert.alert('Foutmelding', 'Er is geen geschikte E-reader gevonden'));
      })
      .catch((err) => {
        Alert.alert('Foutmelding', 'Het downloaden van het boek is niet gelukt');
      })
eddnav commented 7 years ago

Note: previewDocument behaves like openDocument here, it opens a dialog to select an action.

wkh237 commented 7 years ago

@eddnav , thanks for the information 👍 Have you tried it on a device?

eddnav commented 7 years ago

Yup, on a simulator it just shows the same select action dialogue, just more empty, obviously without the iBook options.

On 20 Apr 2017 8:40 a.m., "Ben Hsieh" notifications@github.com wrote:

@eddnav https://github.com/eddnav , thanks for the information 👍 Have you tried it on a device?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wkh237/react-native-fetch-blob/issues/337#issuecomment-295722215, or mute the thread https://github.com/notifications/unsubscribe-auth/AEOr7EgM-ZPTTz_mTa30PYjbGqeJqhLVks5rx1I1gaJpZM4NC4do .