Server Code Unity tutorial

Create a server script in your Unity Project that notifies a user of an event in less than 40min in three steps:

  1. Create server hook
  2. Notify the user
  3. Configure Gamedonia Push
  4. Test it works

Create a server hook

1. Visit your Gamedonia Dashboard.

2. Go to the section Server Code > Server hooks.

3. Click the + button in the userstats row and the Post Save action column.

4. Set the name for the script and click on Create Script.

5. You will see the script editor.

6. Write a comment like this:

/* Sample comment */

7. Click the “Floppy disk” button to save the script.

Server Hook created!

Super easy, right? Let's see what you can do with these hooks in the next step.


Send a push notification

You can create any kind of script you want here: review information, search for the opponent, update some other entities, or send more notifications depending on different scenarios.

In this tutorial, you are going to send a push notification to the user to tell him that a new map was unlocked.

1. Add the following lines of code to the previous script:

var userstats = request.object;
var ownerId =;

var notification = null;

notification = new Object();
notification.type = "newMapUnlocked";
notification.alert = "Congratulations " + userstats.username + "!You have unlocked a new map";
notification.badge = 1;
gamedonia.push.send(notification, ownerId);

2. Click the Floppy disk button to save the script.

Script updated!

What does this script do?

First, it recovers the object that has been sent to the data storage to be saved (request.object), then it recovers the user who stores the entity. Finally, it prepares the notification object to be sent.


Configuring Gamedonia to send push

To enable Gamedonia backend to send push notifications on your behalf it's as easy as uploading your certificates to the Dashboard.

For Android, please check the guide on how to setup the Android Push Notifications

For iOS, please check the guide on how to setup the iOS Push Notifications

Push notifications setup completed!

Cool! Now you can receive notifications from the server side!


Test it works

Push notification received!

Click on the button to download the file you prepared in the DLC tutorial you will receive a push notification saying “Congratulations you have unlocked a new map”. Good job!


Introducing the debugger

You can create more complex scripts using the search API to look for more users, entities and so on. But the best part is that you don’t need to do it from the Dashboard!

Gamedonia offers you a debugger that lets you develop and debug locally to test your scripts, avoiding any web browser failures.

Check how to debug scripts in the Server Code Degugger Guide.


What's next?

The following tutorial will show how to send push notifications to a segmented group of users without coding a single line of code. Find out the advantages of being able to send notifications on-the-fly with the Gamedonia Push Notification Composer.

If you want to check the push notifications tutorial now, just click here .

This is the complete list of tutorials to help you build with Gamedonia Backend:

  1. Facebook login
  2. Data storage
  3. Server Code
  4. Push notifications
  5. In-app purchases
  6. Downloadable content