title: How to view and share a pdf from an URL in a react native app?
body: <p>I have a use-case in my react native app wherein I have to load and display a pdf from an endpoint and also share the same as an attachment(to Gmail app or WhatsApp or even download it) using the native share options (both ios and Android). </p>
  
  <p>I'm currently using the <code>react-native-pdf</code> library to load and show the pdf on the app and it's working fine. The problem is with the share option. I tried using facebook's <a href="https://facebook.github.io/react-native/docs/share#share" rel="nofollow noreferrer">Share API</a> to achieve this but unfortunately, it doesn't serve my purpose as the pdf file is shared as a link and in Android, I had to pass both <code>message and pdfUrl</code> the same value (at least to get the same result across platforms). I want the pdf file to be shared as an attachment when clicked on any of the share options.</p>
  
  <p>below is my code for the same:</p>
  
  <pre><code>class ViewPdfScreen extends Component&lt;Props, {}&gt; {
    render() {
  
      const pdfUrl = 'http://samples.leanpub.com/thereactnativebook-sample.pdf'
  
      const source = {
        uri: pdfUrl,
        cache: true,
        expiration: 900, // cache file expired seconds (0 is not expired)
      };
  
      return (
        &lt;View style={styles.container}&gt;
          &lt;View style={styles.subContainer}&gt;
            &lt;Text&gt;{title}&lt;/Text&gt;
            &lt;TouchableOpacity onPress={() =&gt; this.sharePdf(title, pdfUrl)}&gt;
              &lt;Image source={shareBtn} /&gt;
            &lt;/TouchableOpacity&gt;
          &lt;/View&gt;
          &lt;View style={styles.pdfContainer}&gt;
            &lt;Pdf
              source={source}
              onLoadComplete={(numberOfPages, filePath) =&gt; {
                console.log(`number of pages: ${numberOfPages}`);
              }}
              onPageChanged={(page, numberOfPages) =&gt; {
                console.log(`current page: ${page}`);
              }}
              onError={error =&gt; {
                console.log(error);
              }}
              onPressLink={uri =&gt; {
                console.log(`Link presse: ${uri}`);
              }}
              style={styles.pdf}
            /&gt;
          &lt;/View&gt;
        &lt;/View&gt;
      );
    }
  
    shareBill = (title: string, billUrl: string) =&gt; {
      Share.share(
        {
          message: billUrl,
          url: billUrl,
          title: title,
        },
        {
          // Android only:
          dialogTitle: `Share ${title}`,
          // iOS only:
          excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'],
        },
      )
        .then(res =&gt; console.log(res))
        .catch(error =&gt; console.log(error));
    };
  }
  
  const styles = StyleSheet.create({
    container: {
      flex: 1,
    },
    subContainer: {
      elevation: 4,
      height: 100,
      flexDirection: 'row',
      backgroundColor: colors.orange,
      justifyContent: 'space-between',
      alignItems: 'flex-end',
      padding: 16,
    },
    pdfContainer: {
      flex: 1,
    },
    pdf: {
      flex: 1,
      width: Dimensions.get('window').width,
      height: Dimensions.get('window').height,
    },
  });
  
  export default connect()(ViewPdfScreen);
  
  </code></pre>
  
  <p>Did anyone came across a similar situation or have any solution for this?</p>
  
  <p>want something similar to this below (taken from google)</p>
  
  <p><a href="https://i.stack.imgur.com/SVMv0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SVMv0.jpg" alt="enter image description here"></a></p>