Add image to notification when using sendToTopic method

Viewed 85

I want to use sendToTopic method to send notification to a topic, How can I add image to the notification? There is no option such as notification.imageUrl

1 Answers

It can be done like this -

 const message: TopicMessage = {
  topic: reqData.topic,
  data: {
    abc: reqData.abc
  },
  notification: {
    title: reqData.title,
    body: reqData.body,
    imageUrl: reqData.imageUrl
  }
};

// messageRes is a message ID string.
const messageRes = await admin.messaging().send(message);
Related