{ "notification": { "title": "${title}", "body": "${summary}" } }
To set the message templates to read in from cloud code
var msg = Spark.message("Push"); msg.setPlayerIds(Spark.getPlayer().getPlayerId()); msg.setSendAsPush(true); msg.setMessageData({"title":"push test from pushTestEvent","body":"push test subTitle"}); msg.send();
3. This is a known issue that is in our backlog to fix,we don't have a timeframe for this fix yet.
4.You can add a custom icon to your notification by adding the name of the to the json
"notification": { "title": "${title}", "body": "${summary}", "icon": "myIcon" }
The image called "myIcon" here will need to be added to the projects res/drawable folder, if you don't have this folder already create one.
Regards
Katie
Hi Katie,
Thanks for the quick response, let me add some summary / questions:
Hi Katie,
Thanks for the tip. Where should I call this function? When saving player data?
Thank
Balázs
Hi Balázs
You can call this in your cloud code where you are setting the message text.
For Example
function encode_utf8(s) {
return unescape(encodeURIComponent(s));
}
So for example in Cloud code
var message = encode_utf8("Séan");
function encode_utf8(s) {
return unescape(encodeURIComponent(s));
}
var msg = Spark.message("pushTest");
msg.setPlayerIds(Spark.getPlayer().getPlayerId());
msg.setSendAsPush(true);
msg.setMessageData({"title":message,"body":message});
msg.send();
Regards
Katie
Hi Katie,
Thanks for the answer,
Unfortunately this solution wont work for me, as I use mostly system notifications (like ChallangeLostMessage, or SocialRankChangedMessage).
Thank you anyways.
Balázs
Hi Balázs
For system messages you can use the scripts in cloud code->UserMessges
You can set the message in code by setting script data.
For example to set the main message text in the script
Spark.setScriptData("summary","string message");
In the message set up message template field read in the script data
${scriptData.summary}
Regards
Katie
Balázs Maczák
I am currently trying to send push messages using FCM when one of my friends beats my score in the leaderboard.
There are some aspects of the behavior that is different from what I would expect: