Im attemting to send push messages daily to all the players, the cloude code is working, but the message on the phone just give the Title
How can I send something like: "New Daily Bonus is ${bonusAmount}"
bonusAmount would be set in cloud code?
How should the ScriptMessage Extension look and what should the payload be?
Best Answer
C
Customer Support
said
about 6 years ago
Hi Jacques,
You can use the SparkMessage data to do this. For example if you have a ScriptMessage called "BonusMessage" you could configure the Message Template field to look like this.
Hi, ${data.customName} you have earned ${data.BonusAmount}
Then you could send you message in Cloud Code like this.
//simply replace the bonus amount value with whatever you require. example will send the message to the current player.
var myMessage = Spark.message("BonusMessage")
myMessage.setPlayerIds(Spark.getPlayer().getPlayerId())
myMessage.setMessageData(
{
"customName":Spark.getPlayer().getDisplayName(),
"BonusAmount":100
})
myMessage.send()
Try that and let us know how you get on. If you have any further questions just let us know.
You can use the SparkMessage data to do this. For example if you have a ScriptMessage called "BonusMessage" you could configure the Message Template field to look like this.
Hi, ${data.customName} you have earned ${data.BonusAmount}
Then you could send you message in Cloud Code like this.
//simply replace the bonus amount value with whatever you require. example will send the message to the current player.
var myMessage = Spark.message("BonusMessage")
myMessage.setPlayerIds(Spark.getPlayer().getPlayerId())
myMessage.setMessageData(
{
"customName":Spark.getPlayer().getDisplayName(),
"BonusAmount":100
})
myMessage.send()
Try that and let us know how you get on. If you have any further questions just let us know.
Jacques Leemans
Hi,
Im attemting to send push messages daily to all the players, the cloude code is working, but the message on the phone just give the Title
How can I send something like: "New Daily Bonus is ${bonusAmount}"
bonusAmount would be set in cloud code?
How should the ScriptMessage Extension look and what should the payload be?
Hi Jacques,
You can use the SparkMessage data to do this. For example if you have a ScriptMessage called "BonusMessage" you could configure the Message Template field to look like this.
Hi, ${data.customName} you have earned ${data.BonusAmount}
Then you could send you message in Cloud Code like this.
Try that and let us know how you get on. If you have any further questions just let us know.
Regards,
Liam
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Jacques,
You can use the SparkMessage data to do this. For example if you have a ScriptMessage called "BonusMessage" you could configure the Message Template field to look like this.
Hi, ${data.customName} you have earned ${data.BonusAmount}
Then you could send you message in Cloud Code like this.
Try that and let us know how you get on. If you have any further questions just let us know.
Regards,
Liam
Jacques Leemans
Perfect! Thanks Liam!
-
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