Local And Push Notifications

In this chapter, you will find the example on how to manage local and push notifications for your game.

If you want to show simple notification banner / popup, you can use this function:

UM_NotificationController.instance.ShowNotificationPoup("Hello", "Notification popup test");

Note: In order to use ShowNotificationPopUp you have to check GameCenter in IOSNativeSettings.

 

Scheduling local notification is fairly simple, all you have to do is:

int NotificationId = UM_NotificationController.instance.ScheduleLocalNotification("Hello Locacl", "Local Notification Example", 5);

 

As you probably noticed, this function is returning int notification id. You can use this id if you want to cancel particular local notification. Here is an example:

UM_NotificationController.instance.CancelLocalNotification(NotificationId);

 

And if you want to cancel all scheduled notifications:

UM_NotificationController.instance.CancelAllLocalNotifications();

 

For push notification, it’s a bit more complicated. Basically, the plugin  only gives you a possibility to register the device for push notifications and get the device id which you should send to your server for sending the push notifications in the future.

So, here is an example how you can retrieve the push device id:

UM_NotificationController.instance.OnPushIdLoaded += OnPushIdLoaded;
UM_NotificationController.instance.RetriveDevicePushId();

private void OnPushIdLoaded (UM_PushRegistrationResult res) {
       if(res.IsSucceeded) {
           new MobileNativeMessage("Succeeded", "Device Id: " + res.deviceId);
       } else {
           new MobileNativeMessage("Failed", "No device id");
       }
}

 

The full guides with server code example can be found here:

IOS Push Notifications Guide

Android Google Cloud Messaging Guide