I have configured a push notification using Unity/Firebase for iOS and Android, using and Event to schedule the module and push a message to the player. iOS seems to work fine so far. Android occasionally sends the JSON structure ${data.title} ${data.body} as the push notification, ignoring the message being passed.
This does not happen with every message, it seems to be random. Pushing a message directly from the Firebase console works perfectly.
I think setting the message as null is causing the problems. Can you set up a ScriptMessage Extension. For example in the portal, Go to Configurator->messages->ScriptMessages Extension Create a new ScriptMessages Extension for example called "test_Push" In "tesh_push" set up set the FCM JSON Template (Advanced) with the following
That seems to have done the trick! Thank you very much. :D
Customer Support
said
over 5 years ago
Answer
Hi Daniel
I think setting the message as null is causing the problems. Can you set up a ScriptMessage Extension. For example in the portal, Go to Configurator->messages->ScriptMessages Extension Create a new ScriptMessages Extension for example called "test_Push" In "tesh_push" set up set the FCM JSON Template (Advanced) with the following
I am actually attempting to send a random message/title combination after a set interval. It definitely works sometimes, but every now and then a random message will come through with the structure and no message.
(new to cloud code and gamesparks, So if there is a better way to structure this, I am open to suggestions!)
${data.title} being displayed means that the data in the cloud code isn't being sent correctly. Meaning this line isn't working properly. msg.setMessageData({"title": "Test Title","body": "Test Message"});
Is there any differences in how this is set for notifications or is it all hard coded for testing at the moment?
Daniel Norman
I have configured a push notification using Unity/Firebase for iOS and Android, using and Event to schedule the module and push a message to the player. iOS seems to work fine so far. Android occasionally sends the JSON structure ${data.title} ${data.body} as the push notification, ignoring the message being passed.
This does not happen with every message, it seems to be random. Pushing a message directly from the Firebase console works perfectly.
ScriptMessage template
{
"notification": {
"title": "${data.title}",
"body": "${data.body}"
}
}
Integrations Template (FCM)
{
"notification": {
"title": "${data.title}",
"body": "${data.body}"
}
}
[CODE IN MODULE]
var msg = Spark.message(null);
msg.setPlayerIds([Spark.getPlayer().getPlayerId()]);
msg.setMessageData({"title": "Test Title","body": "Test Message"});
msg.send();
I think setting the message as null is causing the problems.
Can you set up a ScriptMessage Extension.
For example in the portal, Go to Configurator->messages->ScriptMessages Extension
Create a new ScriptMessages Extension for example called "test_Push"
In "tesh_push" set up set the FCM JSON Template (Advanced) with the following
{
"notification": {
"title": "${data.title}",
"body": "${data.body}"
}
}
In cloud code
var msg = Spark.message("test_push");
msg.setPlayerIds([Spark.getPlayer().getPlayerId()]);
msg.setMessageData({"title": "Test Title","body": "Test Message"});
msg.send();
Regards
Katie
- Oldest First
- Popular
- Newest First
Sorted by Newest FirstDaniel Norman
That seems to have done the trick! Thank you very much. :D
Customer Support
I think setting the message as null is causing the problems.
Can you set up a ScriptMessage Extension.
For example in the portal, Go to Configurator->messages->ScriptMessages Extension
Create a new ScriptMessages Extension for example called "test_Push"
In "tesh_push" set up set the FCM JSON Template (Advanced) with the following
{
"notification": {
"title": "${data.title}",
"body": "${data.body}"
}
}
In cloud code
var msg = Spark.message("test_push");
msg.setPlayerIds([Spark.getPlayer().getPlayerId()]);
msg.setMessageData({"title": "Test Title","body": "Test Message"});
msg.send();
Regards
Katie
Daniel Norman
I am actually attempting to send a random message/title combination after a set interval. It definitely works sometimes, but every now and then a random message will come through with the structure and no message.
(new to cloud code and gamesparks, So if there is a better way to structure this, I am open to suggestions!)
var msg = Spark.message(null);
msg.setPlayerIds([Spark.getPlayer().getPlayerId()]);
var titleArray = [
"Need to kill some time?",
"Has another day passed?",
"Crabs - Carrots - Catasaurus Rex",
"Release the KRAKEN!"
];
var textArray = [
"Grab a taco and run with Catasaurus Rex.",
"Spend some quality time wtih the C-Rex.",
"Have you released the Kraken today?",
"There is no better way to waste time, than with C-Rex.",
"Stop reading click bait garbage and get to running!"
];
var textBody = textArray[Math.floor(Math.random() * textArray.length)];
var textTitle = titleArray[Math.floor(Math.random() * titleArray.length)];
msg.setMessageData({"title": textTitle,"body": textBody});
msg.send();
Customer Support
${data.title} being displayed means that the data in the cloud code isn't being sent correctly.
Meaning this line isn't working properly.
msg.setMessageData({"title": "Test Title","body": "Test Message"});
Is there any differences in how this is set for notifications or is it all hard coded for testing at the moment?
Regards
Katie
-
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