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
A
Antonio Donoso
said
over 8 years ago
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.
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.
Nick Dongas
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:
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
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.
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstAntonio Donoso
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.
Nick Dongas
Yep that works for me.
Thanks!
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics