Heroic Labs Documentation

Push notifications #

Push notifications can be used to improve your mobile game in several ways, including:

  • Player engagement: Notify players of new content or events, encouraging them to return to the game and increasing engagement.
  • Retention: By reminding players to come back to the game after a certain amount of time has passed, push notifications can help improve player retention.
  • Monetization: Promote in-game purchases or special offers, encouraging players to spend money within the game.
  • Social interactions: Encourage players to interact with friends or join multiplayer sessions.

In practice, you should keep in mind the timing and frequency of notifications sent, ensuring they are relevant and add value to the player’s experience without being intrusive.

Initialize the local notifications system #

The local notifications system takes an OperatingMode as well as properties for determining if notifications should auto increment native badge number via the constructor.

1
2
3
4
var operatingMode = LocalNotificationSystem.OperatingMode.QueueClearAndReschedule;
var autoBadging = true;
var localNotificationSystem = new LocalNotificationSystem(operatingMode, autoBadging);
systems.Add(localNotificationSystem);

Listing pending notifications #

You can list pending notifications.

1
2
3
4
foreach (var pendingNotification in localNotificationSystem.PendingNotifications)
{
    Debug.Log($"{pendingNotification.Notification.Title} {pendingNotification.Notification.Body}");
}

Creating a notification #

You can create a notification.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var gameNotification = localNotificationSystem.CreateNotification();
gameNotification.Title = "Hello, World!";
gameNotification.Body = "This is a notification.";
gameNotification.SmallIcon = "<IconId>";
gameNotification.LargeIcon = "<LargeIconId>";
gameNotification.Data = new Dictionary<string, string>
{
    {
        "someKey", "someValue"
    }
}.ToJson();

Scheduling a notification for delivery #

You can schedule a notification for delivery.

1
2
var pendingNotification = localNotificationSystem.ScheduleNotification(gameNotification);
Debug.Log($"{pendingNotification.Notification.Id} scheduled for delivery");

Cancelling a notification #

You can cancel a notification.

1
2
3
4
if (pendingNotification.Notification.Id.HasValue)
{
    localNotificationSystem.CancelNotification(pendingNotification.Notification.Id.Value);
}

Cancelling all notifications #

You can cancel all notifications.

1
localNotificationSystem.CancelAllNotifications();

Dismissing a notification #

You can dismiss a notification.

1
2
3
4
if (gameNotification.Id.HasValue)
{
    localNotificationSystem.DismissNotification(gameNotification.Id.Value);
}

Dismissing all notifications #

You can dismiss all notifications.

1
localNotificationSystem.DismissAllNotifications();

Getting last notification #

You can get the last notification.

1
var gameNotification = localNotificationSystem.GetLastNotification();

Pausing notifications #

You can pause notifications.

1
await localNotificationSystem.PauseAsync();

Resuming notifications #

You can resume notifications.

1
await localNotificationSystem.ResumeAsync();

Shutting down the notification system #

You can shutdown the notification system.

1
await localNotificationSystem.ShutdownAsync();