Skip to content Skip to sidebar Skip to footer

Share File With React Native

I use { Share } from 'react-native'. I shared message successfully, no problem. Now, I generate dynamically a PDF and save it at local. Is it possible to share the PDF like when I

Solution 1:

I had the same problem with the share of react native. I just used this library React Native Share.

And you can pass the url to the file in your file system and it will work properly:

 Share.open({
                title: "This is my report ",
                message: "Message:",
                url: "file:///storage/emulated/0/demo/test.pdf",
                subject: "Report",
            })

Solution 2:

This seems to work with the basic Share library from React Native, as long as you have the file:// URL of your PDF file:

Share.share({
  url: `file:///path/to/your/file.pdf`,
  title: 'Download PDF'
})

I've only tested on iOS, so YMMV.

Post a Comment for "Share File With React Native"