title: Open a file (pdf, word, excel, png etc.) on device with its default application in react-native
body: <p>I'm using <a href="https://github.com/itinance/react-native-fs" rel="noreferrer">react-native-fs</a> to download a file(pdf, word, excel, png etc.) and I need to open it in other application. Is it possible to open downloaded file with <a href="https://facebook.github.io/react-native/docs/linking.html" rel="noreferrer">Linking</a> or better open a dialog with possible apps like when using <a href="https://facebook.github.io/react-native/docs/share.html" rel="noreferrer">Sharing</a>? <code>Linking</code> in the code below tries to open the file but it closes immediately without any notification, but my app is still working fine. Is there some special way to build URLs for deep linking for a specific file type? Any ideas for the best solution?</p>
  
  <p>I see that there is old package <a href="https://github.com/huangzuizui/react-native-file-opener" rel="noreferrer">react-native-file-opener</a> but it's no longer maintained. This solution would be great.</p>
  
  <p>Simplified code for download component:</p>
  
  <pre><code>import React, { Component } from 'react';
  import { Text, View, Linking, TouchableOpacity } from 'react-native';
  import { Icon } from 'react-native-elements';
  import RNFS from 'react-native-fs';
  
  import { showToast } from '../../services/toasts';
  
  class DownloadFile extends Component {
    state = {
      isDone: false,
    };
  
    handleDeepLinkPress = (url) =&gt; {
      Linking.openURL(url).catch(() =&gt; {
        showToast('defaultError');
      });
    };
  
    handleDownloadFile = () =&gt; {
      RNFS.downloadFile({
        fromUrl: 'https://www.toyota.com/content/ebrochure/2018/avalon_ebrochure.pdf',
        toFile: `${RNFS.DocumentDirectoryPath}/car.pdf`,
      }).promise.then(() =&gt; {
        this.setState({ isDone: true });
      });
    };
  
    render() {
      const preview = this.state.isDone
        ? (&lt;View&gt;
          &lt;Icon
            raised
            name="file-image-o"
            type="font-awesome"
            color="#f50"
            onPress={() =&gt; this.handleDeepLinkPress(`file://${RNFS.DocumentDirectoryPath}/car.pdf`)}
          /&gt;
          &lt;Text&gt;{`file://${RNFS.DocumentDirectoryPath}/car.pdf`}&lt;/Text&gt;
        &lt;/View&gt;)
        : null;
      return (
        &lt;View&gt;
          &lt;TouchableOpacity onPress={this.handleDownloadFile}&gt;
            &lt;Text&gt;Download File&lt;/Text&gt;
          &lt;/TouchableOpacity&gt;
          {preview}
        &lt;/View&gt;
      );
    }
  }
  
  export default DownloadFile;
  </code></pre>