Skip to content

Fetch current user notification history

If you want to get the user notification history:

NearIT.getNotificationHistory({
    success: function(result) {
        // SUCCESS: YOU GOT NOTIFICATION HISTORY
        var notifications = result.items;
        for (var i = 0; i < notifications.length; i++) {
            console.log(notifications[i]);
        }
    },
    error: function(error) {
        // ERROR: FAILED FETCHING NOTIFICATION HISTORY
        console.log(error);
    }
});

Each item has the following properties:

  • read: a Bool representing whether the notification was ever read or not by the user
  • notificationContent: the NearIT content delivered by that notification (types and properties are described here)
  • trackingInfo: useful for tracking (see below).
  • timestamp: epoch timestamp

Warning: if you are implementing the list yourself, remember to track the items as opened when the user taps on them. See the trackings section to learn how to track a notification as opened.