Show Notifications Inbox

Gameball generates player notifications for the player as he progresses through your Gameball configured program. The notifications generated can be for Challenge achievements, level achievements, wallet points rewards, or any other event as per your program's configurations.

In case you would like to build a custom notification tab/inbox for your player within your app or web page, you can easily achieve this using the Notifications API.

The Notifications API returns a paged list of player’s notifications ordered by date. Each notification item in the list has all the information you need to display the notification.

{
    "notifications": [
        {
            "notificationId" : "123",
            "title": "New level!",
            "body": "Keep it up! You are now on Bronze ",
            "isRead": true,
            "createdAt": "2021-05-12T00:08:09.646174",
            "lang": "en",
            "icon": "https://cdn.gameball.co/uploads/client776/ad8b2587-959f-48fd-ab58-a643323652begb-icon-level-13.png"
        },
        {
            "notificationId" : "124",
            "title": "Congratulations! ",
            "body": "Welcome earned. Enjoy your rewards and keep earning more!",
            "isRead": true,
            "createdAt": "2021-05-12T00:08:09.623367",
            "lang": "en",
            "icon": "https://cdn.gameball.co/uploads/client776/bcc5d9be-3861-415f-bdf9-34b4064a1320Group 2144.png"
        }
    ],
    "count": 50,
    "total": 200
}

For each notification, you have its title, message, icon, and status - if it has been read by the player or not.

Once a notification is seen by the player, you can update Gameball to set the notification as read using the Notifications PUT API. All you have to do is to call the PUT API with the list of notification ids that have been read by the player.

curl -X PUT -H 'apiKey: 807b041b7d35425988e354e1f6bce186' -d '{
        "notificationIds" : ["123", "3441", "3245"]
  }' -v -i 'https://api.gameball.co/api/v3.0/integrations/notifications'

Using the query string filters, you can set the desired inbox page size by setting the limit value. The below API call returns the first page with size of 20 notifications.

https://api.gameball.co/api/v3.0/integrations/notifications/:playerUniqueId?
limit=20

You can also control the desired page by setting the page number as a query filter. The following example returns the second page where a page size is 20 notifications.

https://api.gameball.co/api/v3.0/integrations/notifications/:playerUniqueId?
limit=20&page=2

Using the Lang filter

In case your app or web page supports different locales and changes based on your player’s preferences. After configuring your supported locales in Gameball, you will need the API response text to match the locale of the current player.

To do so, you can provide the optional Lang query filter to your API call so that Gameball can respond using the corresponding configured locale.

In order to better understand how to configure your languages and know their respective language codes, check this article in our Help Center.

For example, if your app supports English and French, and the current player using the app selected French as his preferred language. All you need to do is to call the API as follows:

https://api.gameball.co/api/v3.0/integrations/notifications/:playerUniqueId?
limit=20&page=2&lang=fr

Last updated