N
Novu2y ago
Nexen

empty data payload on fcm

sending
{
"foo":"bar"
}
{
"foo":"bar"
}
and result is in image.
7 Replies
Nexen
Nexen2y ago
bump
Novu_Bot
Novu_Bot2y ago
@the_nexen, you just advanced to level 4!
empe
empe2y ago
@Support
DavidSouthmountain
@raikas I think this is what you are working on... to allow payload as data in fcm message right?
Raikas
Raikas2y ago
Ah yes! I think I documented this actually, let me find it Sending that in payload will use the template (defined in admin panel) and replace handlebars ({{foo}} turns into bar). If you want to send data, you need to do that using overrides
novu.trigger('event-name', {
to: {
subscriberId: '...',
},
payload: {
abc: 'def', // If the notification is a data notification, the payload will be sent as the data
},
overrides: {
fcm: {
type: 'notification',
// type: 'data' => will turn this into a FCM data notification, where the payload is sent as a data notification
data: {
key: 'value',
// If type is "notification", you can use the "data" override to send notification messages with optional data payload
},
},
},
});
novu.trigger('event-name', {
to: {
subscriberId: '...',
},
payload: {
abc: 'def', // If the notification is a data notification, the payload will be sent as the data
},
overrides: {
fcm: {
type: 'notification',
// type: 'data' => will turn this into a FCM data notification, where the payload is sent as a data notification
data: {
key: 'value',
// If type is "notification", you can use the "data" override to send notification messages with optional data payload
},
},
},
});
In this case I believe you should set the type to 'data'
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
serafeimo
serafeimo17mo ago
Hey @raikas ! I'm using Novu's API to trigger notifications and I'm trying to add "data" in the message but it doesn't seem to be working. How would you suggest to construct the request? The FCM message directly from Firebase (v1 version) is:
"message": {
"token": "1234",
"notification": {
"body" : "something here",
"title": "bla bla bla"
},
"data": {
"action": "user_weblink",
"url": "https://www.cnn.com"
}
}
"message": {
"token": "1234",
"notification": {
"body" : "something here",
"title": "bla bla bla"
},
"data": {
"action": "user_weblink",
"url": "https://www.cnn.com"
}
}