Sign In Register

How can we help you today?

Start a new topic
Answered

Push Notification Message Format

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?




Best Answer

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.


Regards,

Liam


Answer

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.


Regards,

Liam

Perfect! Thanks Liam!

Login to post a comment