0

I'm sending images and pdf through gifted chat with twilio messaging. After sending I'm having trouble to show documents in gifted-chat ui.

Here is the message object which gifted chat will accept:

{
  _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
}

How can i attach pdf(document) link in here,

Currently am attaching pdf url with key of image and it is returning blank coz it is recognising that url as an image.

How can i show pdf instead of blank their?

Here is the current resultImage

Rahman Haroon
  • 1,088
  • 2
  • 12
  • 36

1 Answers1

1

I think you can define "document" in your message object rather than using "image". Then you can customize your document message in the props renderCustomView like this:

// Custom render message
const renderCustomView = (props) => {
// Custom document message
  if (props.currentMessage.document) {
    // Your custom pdf message
  }
}
Lewis
  • 41
  • 5