Sets a local notification to be shown at a given time on a given date.


GML Code Example

push_local_notification(fire_time, title, message, data);

Argument Description
fire_time The date/time to fire the off the notification
title The notification title (a string)
message The notification message text (a string)
data The data package to send to your game (a string)

Returns: N/A


This function can be used to set a local notification to be shown on a given date at a given time. The "fire_time" is the date/time that the notification should be pushed to the user device (you can use the GameMaker: Studio Date and Time Functions to get this), and you can give the notification a title and a message text as well as a payload string which will be passed to your game when the users taps the notification.

NOTE: The "title" argument is ignored on iOS and the game name is shown instead.

Tapping the notification will start the game on the device and trigger an Asynchronous Push Notification event with a ds_map which can then be parsed to check the payload string and perform whatever action is required.

NOTE: This function is limited to the iOS and Android target modules.

Extended Example

In this example we will send a local push notification using the following code:

GML Code Example

var fireTime = date_inc_day(date_current_datetime(), 1);
 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: Async Event in the following way:

GML Code Example

var type = ds_map_find_value(async_load, "type");
 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;

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here