Skip to content

Advanced Notification History

If you want to show the notification history with your own UI, just call the following method to get the history:

const history = await NearIT.getNotificationHistory();

Each item has the following properties:

Name Description
read true if it has been read, false otherwise.
timestamp Epoch (in seconds).
trackingInfo A string to use when sending trackings back to NearIT.
message The notification message.
type A string that identifies the type of NearIT content.
notificationContent The content.
isNew a boolean representing whether the notification is new for the user. Its value is the same as read, unless you use markNotificationHistoryAsOld to mark all previous notifications as old. See the Updates chapter to learn more.

notificationContent object follows the structure described in the previous section.


To get notified on notification history updates, you can set a listener:

this.historyUpdateSubscription = NearIT.addNotificationHistoryUpdateListener(history => {
    console.log(`Notification history update! Count: ${history.filter(item => item.isNew).length}`)

N.B: Remember to unsubscribe from updates (you'd want to do this when the component is unmounted)


If you want to update a badge you should use the isNew field to count new notifications. By default, this field will be the same as read, so any tracking regarding the item can change its value. If you want to manually set all the notification as acknowledged (meaning that isNew will be false), without loosing the read information or tracking every single notification interaction, you can call this method: