N
Novuβ€’2y ago
serafeimo

FCM notification & data objects (v0.11.0)

Hi all! I know that there are a couple of discussions about this subject but I created this one hoping to clear things out a little bit. As I've seen from FCM documentation (v1), while sending a message, one can specify two objects: notification, data. For example:
{
"message": {
"token": "device-token",
"notification": {
"body" : "Title here",
"title": "Message body"
},
"data": {
"action": "go_to_link",
"url": "https://www.novu.com"
}
}
}
{
"message": {
"token": "device-token",
"notification": {
"body" : "Title here",
"title": "Message body"
},
"data": {
"action": "go_to_link",
"url": "https://www.novu.com"
}
}
}
However, from my testing with Novu so far, when I add the data type in the overrides field, it sends the data but it omits the title&message fields from the template. So, the data fields are sent to the device but the message is empty.. Event trigger example:
{
"name": "fcm-test",
"to": {
"subscriberId": "sera-12345"
},
"payload": {
"title": "Title here",
"body": "I am the body",
"action": "go_to_link",
"url": "https://www.novu.com"
},
"overrides": {
"fcm": {
"type": "data"
}
}
}
{
"name": "fcm-test",
"to": {
"subscriberId": "sera-12345"
},
"payload": {
"title": "Title here",
"body": "I am the body",
"action": "go_to_link",
"url": "https://www.novu.com"
},
"overrides": {
"fcm": {
"type": "data"
}
}
}
I'd appreciate any comments or thought on this πŸ˜… Thanks!
3 Replies
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
serafeimo
serafeimoOPβ€’2y ago
It works exactly as @sheena suggested. Keep in mind that all fields in "data" object need to be strings, even numbers and booleans. For example:
{
"name": "fcm-test",
"to": {
"subscriberId": "sera-12345"
},
"payload": {

},
"overrides": {
"fcm": {
"data": {
"action": "an_action_to_be_handled_on_device",
"anIdThatINeed": "9430124",
"aBooleanThatINeed": "false"
}
}
}
}
{
"name": "fcm-test",
"to": {
"subscriberId": "sera-12345"
},
"payload": {

},
"overrides": {
"fcm": {
"data": {
"action": "an_action_to_be_handled_on_device",
"anIdThatINeed": "9430124",
"aBooleanThatINeed": "false"
}
}
}
}
A big thanks to @sheena for all the help!! πŸ™‚
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server