Owner website sama sekali tidak perlu menambahkan subscriber secara manual. Begitu kode SDK dipasang di website klien, jumlah subscriber akan bertambah sendiri secara otomatis setiap kali ada pengunjung yang mengklik tombol izin notifikasi.
Owner menaruh file pushnotif-sw.js di root domain dan menempelkan 1 baris script SDK sebelum </body>.
Pengunjung membuka web klien & menekan tombol Lonceng. Browser meminta izin resmi ke Google FCM / Apple APNs.
SDK mengirim token terenkripsi ke server PushNotif. Angka Subscriber Aktif di Dashboard langsung naik (+1) otomatis!
pushnotif-sw.js di Root Domain KlienStandar keamanan browser W3C mewajibkan file Service Worker berada di root domain klien (contoh: https://daftarkajian.web.id/pushnotif-sw.js) agar notifikasi muncul 100% atas nama domain & logo perusahaan klien. Buat file bernama pushnotif-sw.js di folder publik utama website Anda dengan isi 1 baris ini:
importScripts("https://pushnotif.biz.id/sdk/pushnotif-sw.js");
</body>Dengan opsi autoPrompt: true, SDK otomatis memunculkan Tombol Lonceng Melayang di pojok kanan bawah bagi pengunjung yang belum berlangganan:
<script src="https://pushnotif.biz.id/sdk/pushnotif.js"></script>
<script>
PushNotif.init({
appId: "app_45fd19f5", // Ganti dengan App ID website Anda
apiBase: "https://pushnotif.biz.id",
autoPrompt: true,
promptLabel: "Ikuti Info Kajian Terbaru"
});
</script>
Selain mengirim broadcast manual dari Dashboard, server backend Anda (Node.js, PHP, Python, Go, Laravel) dapat mengirim push notification otomatis menggunakan Secret API Key:
curl -X POST https://pushnotif.biz.id/api/v1/notifications \
-H "Content-Type: application/json" \
-H "Authorization: Bearer pn_live_API_KEY_ANDA" \
-d '{
"app_id": "app_45fd19f5",
"title": "Jadwal Kajian Ba'da Maghrib Malam Ini",
"body": "Bersama Ustadz di Masjid Agung. Klik untuk melihat lokasi & materi.",
"url": "https://daftarkajian.web.id/jadwal-hari-ini"
}'
Endpoint POST /api/v1/notifications mendukung 5 format payload sekaligus (Standar JSON, OneSignal JSON, Firebase FCM JSON, Form URL-Encoded untuk PHP/WordPress, serta Query Parameters untuk Webhook n8n/Zapier):
await fetch("https://pushnotif.biz.id/api/v1/notifications", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer pn_live_API_KEY_ANDA"
},
body: JSON.stringify({
app_id: "app_45fd19f5",
title: "Pesanan #INV-992 Dikirim!",
body: "Kurir sedang menuju lokasi Anda.",
url: "https://tokoanda.com/orders/992"
})
});
$ch = curl_init("https://pushnotif.biz.id/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: pn_live_API_KEY_ANDA"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
"app_id" => "app_45fd19f5",
"title" => "Pembayaran Diterima!",
"message" => "Terima kasih, paket Anda sedang disiapkan.",
"link" => "https://tokoanda.com/pesanan"
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
# 1. URL LAMA ONESIGNAL (Ganti baris ini saja):
# ❌ POST https://onesignal.com/api/v1/notifications
# ❌ POST https://api.onesignal.com/notifications
# 2. URL BARU PUSHNOTIF (Path /api/v1/notifications SAMA PERSIS!):
# ✅ POST https://pushnotif.biz.id/api/v1/notifications
curl -X POST https://pushnotif.biz.id/api/v1/notifications \
-H "Content-Type: application/json" \
-H "Authorization: Basic pn_live_API_KEY_ANDA" \
-d '{
"app_id": "app_45fd19f5",
"headings": { "en": "Promo Akhir Bulan!", "id": "Promo Akhir Bulan!" },
"contents": { "en": "Diskon 40% khusus hari ini.", "id": "Diskon 40% khusus hari ini." },
"url": "https://tokoanda.com/promo"
}'