Sign In Register

How can we help you today?

Start a new topic
Answered

Generating custom push notifications

Hi,


I am having trouble configuring the message contents of a custom push notification. I am calling the following cloud code to send the message:

Spark.sendMessage({"alert" : "A new game has begun!"}, sparkPlayers);

However when I try to modify the ScriptMessage template to dynamically generate the message I cannot retrieve the script items. I've tried ${alert}, ${scriptData.alert} and even ${scriptData.myKey.alert} but the result is always the same in that it just sends down the plaintext in the template. Can you tell me what I am doing wrong here?


Cheers


Best Answer

Hi,


It seems there's a mistake on the manual page. On the ScriptMessage, the message is stored under "data", so you have to put ${data.alert} for the notification.

At least, this works for me when sending script messages.


Answer

Hi,


It seems there's a mistake on the manual page. On the ScriptMessage, the message is stored under "data", so you have to put ${data.alert} for the notification.

At least, this works for me when sending script messages.

Yep that works for me. 


Thanks!