2

Can any one help me through react native gifted chat? I want to share files like (.pdf, docs, .txt, .jpg.) How to do that?

Supriya Gorai
  • 352
  • 3
  • 16
  • 1
    Check out https://stackoverflow.com/help/how-to-ask if you want to get some help. You're better off asking on dev.to or some other platform, if you want a plain tutorial! – walidvb Aug 21 '20 at 10:07
  • @SupriyaGoarai were you able to sort it out – Ismail Iqbal Feb 07 '21 at 11:14

2 Answers2

2

You have to use renderCustomView (Function) - Custom view inside the bubble prop. And add some meta information into your message data like this is a SPECIAL message and finally test in renderCustomView if you are in the case of a special message.

1

react-native-gifted-chat already includes support for images and videos, using the properties video and image of IMessage, just past pass the the link of the resource

{
  _id: 1,
  text: 'My message',
  createdAt: new Date(Date.UTC(2016, 5, 11, 17, 20, 0)),
  user: {
    _id: 2,
    name: 'React Native',
    avatar: 'https://facebook.github.io/react/img/logo_og.png',
  },
  image: 'https://facebook.github.io/react/img/logo_og.png',
  // You can also add a video prop:
  video: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4',
  // Mark the message as sent, using one tick
  sent: true,
  // Mark the message as received, using two tick
  received: true,
  // Mark the message as pending with a clock loader
  pending: true,
  // Any additional custom parameters are passed through
}

For the rest of types you have to implement your own logic, using one of the render functions, i think you could renderMessageImage with a link to the icon of the resources and add a description, also you should handle the click event to start download

Wilch
  • 36
  • 1
  • 2