List Notifications and Mark as Read In-Game
In this How-to, we’ll get all unread notifications for the logged in player, find a specific notification by a key and mark it as read.
Prerequisites
There are a few different systems that can cause notifications in LootLocker
Purchasing a Catalog Item
Custom notifications from the admin api, Server SDK (using the SendNotificationToPlayer methods), or through the console (go to a player in the player list, choose actions, and "Send Notification").
A previously sent notification from for example an invoked trigger or a successful purchase.
To get the matched notification to a previous action (an invoked trigger, a purchase call), you need one or more of the following:
A purchase using virtual currency: use the
catalog_listing_idAn In App Purchase using Apple App Store: use the
transaction_idAn In App Purchase using Google Pla Store: use the
product_idAn In App Purchase using Steam Store: use the
entitlement_idA trigger: use the
trigger_keyA twitch drop: use the
twitch reward idA custom notification from server, console, or admin api: use the notification type you set for the notification.

Input
In this example, we're filtering notifications by their source using the triggers string. Other filters include:
Show Read: Set to true to include previously read notifications.
Priority: Fetch notifications of a specific priority.
Of Type: Fetch notifications of a specific type, such as PullRewardAcquired for triggers and purchased items. If there are many notifications, use pagination to navigate through the data.
Mark as read
Once a notification is processed in your game logic, mark it as read. This will exclude it from future requests unless you specifically request read notifications. This action should be applied to each item in the list of handled notifications.
Logic for handling Notifications
When listing notifications, branch the completed event based on the success flag and add error handling for failed requests.
Note on Pagination: The notification response includes pagination data to help you navigate large notification lists.
We recommend branching the completed event from listing notifications on the success flag, and if you do this you will probably want to add error handling in case the request fails.
Here, we retrieve only unread notifications from the triggers source with default pagination (up to 10 items). We then filter further by SuccessfullyInvokedTriggerKey to narrow the list to specific triggers.

In this example, we simply print the notification info. Adapt this step to handle notifications based on your game’s requirements. Here, we assume that SuccessfullyInvokedTriggerKey provides a currency reward and only expand that information.
For a more general approach, iterate over all notifications to handle various sources and types relevant to your game. The example below outlines how to extract different types of rewards.

Conclusion
In this How-to, we’ve listed a notification and marked it as read. Notifications are to be called after a purchase has been made or after an invoked trigger.
Last updated