Notify Aim helps you send Web, Android, Desktop Push Notifications, automate WhatsApp, and Chatbots, and manage real-time broadcasting for your audience.
1- Add the following script before your website’s closing </body> tag:
<script src="https://api.notifyaim.com/sdk/v1/notification/web-push-client.js"> </script>
<script>
window.onload = function() {
NotifyAim.init({
vapidKey: "YOUR_VAPID_KEY", // Found in Dashboard → Website Settings
});
}
</script>
2- On your domain root /notifyaim-sw.js: example: https://example.com/notifyaim-sw.js
self.addEventListener("push", function (event) {
const data = event.data.json();
// Support Notify Aim structure (notification + data)
const notif = data.notification || {};
const extra = data.data || {};
event.waitUntil(
self.registration.showNotification(notif.title || "Notification", {
body: notif.body || "",
icon: notif.icon || "/logo.png",
image: notif.image || null,
tag: notif.tag || "default",
renotify: notif.renotify || false,
actions: notif.actions || [], // buttons if any
sound: notif.sound || undefined, // Android only
// Pass extra data for click handling
data: {
url: extra.url || "/",
click_behavior: extra.click_behavior || "open_url",
webhook: extra.webhook || null,
url_buy: extra.url_buy || null,
url_cart: extra.url_cart || null,
priority: extra.priority || "normal",
channelId: extra.channelId || "general",
},
})
);
});
// Click event listener
self.addEventListener("notificationclick", function (event) {
event.notification.close();
const data = event.notification.data || {};
switch (event.action) {
case "buy_now":
if (data.url_buy) clients.openWindow(data.url_buy);
break;
case "add_cart":
if (data.url_cart) clients.openWindow(data.url_cart);
break;
case "signup":
if (data.url_signup) clients.openWindow(data.url_signup);
break;
case "read_blog":
if (data.url_blog) clients.openWindow(data.url_blog);
break;
default:
// Default click (notification body)
if (data.click_behavior === "open_url" && data.url) {
clients.openWindow(data.url);
} else if (data.click_behavior === "open_webhook" && data.webhook) {
fetch(data.webhook, { method: "POST" });
}
break;
}
});
📌 Tip for Beginners: You don’t need coding skills if you’re using WordPress — use our Notify Aim WordPress Plugin instead.
Choose how you want visitors to subscribe:
Example (Custom Trigger):
document.getElementById('notifyButton').addEventListener('click', () => {
NotifyAim.subscribe();
});
You can now:
➡ Go to the API Documentation if you want to integrate Notify Aim into custom apps.
➡ Check the Integration Guide for platform-specific setup.