Sign In Register

How can we help you today?

Start a new topic

Send challenge object in push notifications as JSON

Hello developers!


I have some problems with sending object challenge in the ChallengeChatMessage as JSON. Here is my template for android:

{

  "tickerText": "${summary}",

  "subtitle": "${subTitle}",

  "title": "${subTitle}",

  "messageCount": "1",

  "action": "Chat",

  "challengeJson": {

    "accepted": "${challenge.accepted}",

    "challenged": "${challenge.challenged}"

  },

  "chatPlayerName": "${who}"

}


I don't know what I do wrong, but property "challengeJson" comes on devices as string and it's not json object. 

Here is an example, what I get on devices:

{"google.sent_time":1512575388252,"challengeJson":"{accepted=[{externalIds={}, id=59f0989e9c25746bdac75d4c, name=Nickname369}, {externalIds={}, id=5a264d059c25746bdaccdd35, name=G11}], challenged=[{externalIds={}, id=5a264d059c25746bdaccdd35, name=G11}]}","title":"Nickname369 just said '987'","tickerText":"Nickname369 just said '987'","subtitle":"Nickname369 just said '987'","action":"Chat","chatPlayerName":"Nickname369","messageCount":"1","from":"212958543909","google.message_id":"0:1512575388268882%a8cdc1fef9fd7ecd"} 


Could you please show me, what I do wrong?


With regards,

German

1 Comment

Hi German

This data is already sent as json with the message, if  you want it in the format above you can add it to script data in the ChallengeChatMessage script
var challengeJson = [];
challengeJson.push({"accepted":Spark.getData().challenge.accepted,"challenged":Spark.getData().challenge.challenged});
Spark.setScriptData("challengeJson", challengeJson);

The gamesparks ChallengeChatMessage listener will pick the message.

Regards
Katie





 

Login to post a comment