One of the most-requested features from Aimtell developers is finally here: a complete push notification inbox API baked right into our JavaScript SDK. With four new functions added to trackpush.js, you can now read, mark, and delete a subscriber's push notification history directly from the browser — no backend integration required. In this post, we'll walk through the new Aimtell JavaScript API functions, show working code examples for each, and demonstrate how to combine them into a fully functional in-page notification inbox.
Aimtell's trackpush.js SDK has long offered helpers for working with the current subscriber — getting their info, updating their attributes, segmenting them, and more. We've extended that toolkit with four new functions focused on the subscriber's stored web push notifications:
_aimtellGetNotifications() — returns the subscriber's full notification history_aimtellMarkNotificationsRead(timestamp) — marks one or all notifications as read_aimtellMarkNotificationsUnread(timestamp) — marks one or all notifications as unread_aimtellDeleteNotifications(timestamp) — deletes one or all notificationsAll four functions return native Promises, follow the same XHR pattern as Aimtell's existing _aimtellGetSubscriber* helpers, and require zero new dependencies. They hit the new https://notifications.aimtell.com service and are automatically scoped to the current site (_at.idSite) and subscriber (_at.subscriber) — the same identifiers Aimtell already manages for you during init.
Native browser push notifications are ephemeral. They appear, the user clicks (or doesn't), and they vanish. That's a problem if a subscriber misses a notification while their browser is closed, on do-not-disturb, or simply scrolling past too fast. A persistent in-page notification inbox solves this by giving subscribers a way to see, revisit, and act on every push you've sent them.
With Aimtell's new SDK functions, you can now ship features like:
Before using the new functions, make sure you have Aimtell's standard installation in place. Specifically, both _at.idSite and _at.subscriber must be set on the page — this is handled automatically by the standard Aimtell init script. The four functions will reject if the subscriber hasn't yet opted in to push.
The starting point for any notification inbox is reading the history. _aimtellGetNotifications() returns a Promise that resolves to an array of notifications, sorted most-recent first.
_aimtellGetNotifications().then(function(notifications) {
console.log(notifications);
// [{ title, body, icon, link, read: true|false, timestamp }, ...]
}); Each item in the response array contains the following fields:
title — the notification's titlebody — the notification's body texticon — the icon URL displayed with the pushlink — the destination URL the notification points toread — true if read, false if unreadtimestamp — the unique key used to target a single notification in the functions belowThe timestamp field is important: it's the identifier you'll pass to the mark-as-read, mark-as-unread, and delete functions when you want to act on a single notification. Pass it through unchanged — don't reformat or convert it.
A common UI pattern is a bell icon in your site header with an unread count badge. Here's how you'd populate it:
_aimtellGetNotifications().then(function(notifications) {
var unread = notifications.filter(function(n) {
return !n.read;
}).length;
document.getElementById("notif-count").innerText = unread;
}); _aimtellMarkNotificationsRead() updates the read flag on the subscriber's stored notifications. Pass a timestamp from the response above to mark one notification, or call with no arguments to mark every notification as read at once — perfect for a “Mark all as read” button.
// mark all as read
_aimtellMarkNotificationsRead().then(function(res) {
// { updated: <count> }
console.log("Marked " + res.updated + " notifications as read");
});
// mark one as read
_aimtellMarkNotificationsRead(1711900000).then(function(res) {
// { updated: 1 }
}); Both forms resolve to an object containing an updated count, so you know exactly how many records were touched. Use it to update your UI optimistically or to confirm the mutation succeeded.
Sometimes a user wants to mark a notification back to unread — a “come back to this later” signal. _aimtellMarkNotificationsUnread() mirrors the read function exactly: pass a timestamp for one, or omit the argument to flip every notification back to unread.
// mark all as unread
_aimtellMarkNotificationsUnread().then(function(res) {
// { updated: <count> }
});
// mark one as unread
_aimtellMarkNotificationsUnread(1711900000).then(function(res) {
// { updated: 1 }
}); When a subscriber wants to clear out their inbox, use _aimtellDeleteNotifications(). As with the other functions, pass a timestamp to remove one notification or omit it entirely to wipe every notification from the subscriber's history.
// delete all
_aimtellDeleteNotifications().then(function(res) {
// { deleted: <count> }
});
// delete one
_aimtellDeleteNotifications(1711900000).then(function(res) {
// { deleted: 1 }
}); Deletes are permanent. Once a notification is removed from the subscriber's history, it cannot be recovered — if you want a “trash” pattern, prefer marking-as-read over deleting.
Here's a complete, dependency-free example that wires up a basic inbox. It renders the subscriber's notifications, marks each as read on click, and exposes a “Clear all” button. Drop it on any page that has Aimtell's standard install code.
<div id="inbox"></div>
<button id="clear-all">Clear all</button>
<script>
function renderInbox() {
_aimtellGetNotifications().then(function(notifications) {
var html = notifications.map(function(n) {
var weight = n.read ? "normal" : "bold";
return '<a href="' + n.link + '" data-ts="' + n.timestamp +
'" style="font-weight:' + weight + '">' + n.title + '</a>';
}).join("<br>");
document.getElementById("inbox").innerHTML = html;
});
}
document.getElementById("inbox").addEventListener("click", function(e) {
var ts = e.target.dataset.ts;
if (ts) _aimtellMarkNotificationsRead(Number(ts));
});
document.getElementById("clear-all").addEventListener("click", function() {
_aimtellDeleteNotifications().then(renderInbox);
});
renderInbox();
</script> That's a fully functional push notification inbox in roughly 25 lines of JavaScript. From here, you can layer in your own styles, pagination, filtering by read status, or chain the Promises with the existing _aimtellGetSubscriber* helpers to enrich the UI with subscriber-specific data.
_aimtellGetNotifications() so the UI matches the server state._at.subscriber isn't set._aimtellGetNotifications(). Don't parse, format, or compare it — it's an identifier, not a display value._aimtellDeleteNotifications() with no argument.| Function | Argument | Resolves To |
|---|---|---|
_aimtellGetNotifications() | none | Array of notification objects |
_aimtellMarkNotificationsRead(ts?) | timestamp or none | { updated: <count> } |
_aimtellMarkNotificationsUnread(ts?) | timestamp or none | { updated: <count> } |
_aimtellDeleteNotifications(ts?) | timestamp or none | { deleted: <count> } |
The new notification-management functions in trackpush.js turn Aimtell's JavaScript SDK into a complete push notification platform — not just for sending pushes, but for letting subscribers engage with their history long after the original push has come and gone. That's a powerful re-engagement surface, and it's now just a few lines of code away.
For full method signatures and additional details, head to the JavaScript Functions section of developers.aimtell.com. Or jump straight into your Aimtell dashboard to start using these functions on your live site.
Not yet using Aimtell? Start your free 14-day trial and ship a fully featured web push notifications inbox for your subscribers in an afternoon.