BunkClub

Next.js PWA

Firebase Cloud Messaging • Native Web Push

SW Inactive

Fix Applied: Push Notifications Now Deliver When App Is Closed

Previously, push notifications failed when closed because the Service Worker was missing direct Web Push listeners and root scope bindings. We implemented:

1. Root Service Worker

/firebase-messaging-sw.js listens 24/7 in background.

2. Dual Push Handler

Dual Firebase compat & native push listener catches all payloads.

3. iOS & Android PWA

Standalone manifest enables background push on iOS 16.4+ & Android.

Device Permission & FCM Token

Permission status: DEFAULT

Test 1: App Closed Simulator

Want to test immediately on your phone or laptop? Click the button below, then lock your screen or minimize the browser tab. The Service Worker will wake up in 5 seconds and deliver the push banner!

Test 2: Cloud Messaging Push

Send from Terminal / Backend (cURL Example)

curl -X POST https://fcm.googleapis.com/fcm/send \
  -H "Content-Type: application/json" \
  -H "Authorization: key=YOUR_FCM_SERVER_KEY" \
  -d '{
    "to": "DEVICE_FCM_TOKEN",
    "priority": "high",
    "notification": {
      "title": "BunkClub Alert",
      "body": "Hey! Testing push when the app is closed 🚀",
      "icon": "/icons/icon-192.png",
      "click_action": "/"
    },
    "webpush": {
      "headers": { "Urgency": "high" },
      "notification": { "requireInteraction": true }
    }
  }'

How to Host on Hostinger

Option 1: Hostinger Shared / Web Hosting (Fastest & Free)

Run npm run build in static export mode. Next.js generates an out/ directory. Simply open Hostinger File Manager and upload all contents of out/ into your public_html! Ensure SSL (HTTPS) is activated in Hostinger (free Let's Encrypt), because Web Push requires HTTPS.

Option 2: Hostinger VPS / Cloud (Node.js)

Upload this project, run npm install, then npm run build, and start it with PM2 or npm start.