The Push Notification Event is one that is triggered by the call back from push notifications on the device OS, either from a local source using the function push_local_notification, or from a remote source (ie: your server). It generates a ds_map (more commonly known as a "dictionary") that is exclusive to this event and is stored in the special variable async_load (please see the individual functions that trigger asynchronous events for code examples that explain the use of this event in further detail). This ds_map has the following keys:
- "type": Value can be "local" for a device local notification, "remote" for a remote notification, or "register" for remote notification registration.
- "status": Value will be "1" for success or "0" for an error.
There may be additional key entries based on the "type" returned and the "status" value. For "status", if an error has been returned ("0"), then you will also have the following key:
- "error": Contains details of the error received.
If the "status" value is 0 (ie: no errors) then the ds_map will contain the following additional values, depending on the value of the "type" key:
- "reg_id": If the "type" received was "register", then this key will hold the device registration id for remote notifications.
- "data": If the "type" received was "local" or "remote", then this key will hold the string payload that you defined when you called the notification function.
In this example we will send a local push notification using the following code:
var fireTime =
var data = "daily_reward";
push_local_notification(fireTime, "Ahoy!", "Catch The Haggis Has A Present", data);
This will set a timer to "push" a notification to the device when one day has passed. When the day is up, if your game is either in the background or not running, a notification will be shown to the user with the given title and message (on iOS, the game name is shown and the title is ignored), and then an asynchronous Push Notification Event will be called. Note that if the game is in the foreground when the time for the notification comes, it will not be shown, but the asynchronous event will still trigger. In the event itself you would handle the callback something like this:
var type = ds_map_find_value(async_load,
var status = ds_map_find_value(async_load, "status");
if status == 0
//error of some kind
var error = ds_map_find_value(async_load, "error");
show_debug_message("error=" + string(error));
if type == "register"
global.reg_id = ds_map_find_value(async_load, "reg_id");
var data = ds_map_find_value(async_load, "data");
if data == "daily_reward"
global.Gold += 1000;
NOTE: The variable async_load is only valid in these events, as the ds_map that is points to is created at the start of the event, then deleted again at the end, with this variable being reset to a value of -1.