Canceling notifications
There are several reasons why we may want to cancel notifications. This could be due to the fact that, during play, the player has made a decision that has caused something to no longer be relevant.
For this example, let’s create a sample notification that we will cancel before it has a chance to happen. But for us to cancel a notification, we must have a way of knowing which notification is which. Thankfully, the Notifications Manager has a property called an Id
that each notification has. We can set the notification ourselves by hand or Unity will generate it for us. In our case, we will use the automatically generated one:
- Open up the
NotificationsController
script and go to theShowNotification
function. Update it to the following:public int? ShowNotification(string title, string body, DateTime deliveryTime) { IGameNotification notification = notificationsManager.CreateNotification(); ...