Send challenge object in push notifications as JSON
G
German Krasnikov
started a topic
about 3 years ago
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
Customer Support
said
about 3 years ago
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);
German Krasnikov
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