Sign In Register

How can we help you today?

Start a new topic

FCM push notifications template

I have FCM push notifications set up and working but the message template isn't working properly. I am using the one from the example in the docs:

{
  "notification": {
  "title": "${data.title}",
  "body": "${data.body}"
  }
}

The notifications pop up on the phone (for example when issuing a challenge) but the message displayed is always "${data.title}" as if the template isn't being parsed. Is the syntax not correct here? I copy-pasted it from this page.


Any help is appreciated. Thanks!


What code are you running to send the FCM ? If your code doesn't have: .setMessageData({"title": "Some Title", "body":"Some body"})

then nothing will be set for those values and will be sent as plaintext.

Oh. I wasn't running any code. The ChallengeIssuedMessage sends the push notification. I was assuming the default message template there "${who} just challenged you at ${challenge.challengeName}." would be passed on as data?

Hmmm not sure. I customized a single payload the way I wanted, and I just override the Global messages in cloudcode and always send as a ScriptMessage. To me, having one syntactically similar payload is easier than changing your client code for each individual message you can recieved. 

I dug a little deeper and it seems that the parameters being sent with the default messages are 'title', 'subTitle' and 'summary'. It is working now using the following template:

{
  "notification": {
    "title": "${title}",
    "body": "${summary}",
    "sound": "default"
  }
}

Thanks!


1 person likes this

Rocket Vulture, it still doesn't work. Where did you put that template? In the integrations page or the message one?

I use that template on the integrations page. On the message page I just left it default as 'null'.

Login to post a comment