Skip to main content
Version: Release

Displaying Notification History

Users can access all of their notifications from Notifi across all dapps in the Notifi Hub. A sample is shown in the image below:

Example hub notif

It is also possible to display the user's past notifications directly in the dapp. The React Card contains the required UI elements and will show the user's notification history when a wallet is connected.

For a more flexible UI to show the users notification history, the Frontend Client provides a getNotificationHistory() function.

Get Notification History using Notifi Frontend Client

To retrieve notification history, use the getNotificationHistory() function:

const getNotificationHistory = async (first?: number, after?: string) => {
// Fetch `first` items after the `after` cursor (leave undefined for first page)
const { nodes , pageInfo } = await client.getNotificationHistory({
first,
after,
});

nodes.forEach(item => {
if (item.detail?.__typename === 'BroadcastMessageEventDetails') {
console.log('I have a broadcast message', item.detail?.subject, item.detail?.message);
}
});

console.log('pageInfo', pageInfo.hasNextPage, pageInfo.endCursor);

return {
nodes,
pageInfo
}
}