push-notifications-setup

Push notifications — env & akun (Fase 0)

Setup manual sekali sebelum push/email hidup di production.

Status lokal (2026-08-15)

ItemStatus
Migration 023 di mpcdb (localhost:5432)Done
mpc-be FCM (FCM_PROJECT_ID + credentials) + ResendDone (lihat mpc-be/.env)
Android google-services.json (com.mpc.app)Done (project mpclub-a3b1e)
POS google-services.json (com.mpc.mpc_pos)Done (app Firebase dibuat via CLI)
Admin/Owner NEXT_PUBLIC_FIREBASE_* + MPC_BE_URL + ADMIN_API_KEYDone
Web Push VAPID keyMasih manual (lihat bawah)
iOS / APNsDitunda (mpc-dev/docs/tasks.md)

Firebase (FCM)

  1. Buat Firebase project untuk MPC.
  2. Tambah app: Android package, iOS bundle ID, Web (Admin + Owner bisa share project; bedakan via appId/token metadata), Flutter POS.
  3. Unduh:
    • google-services.json → Android / POS Android
    • GoogleService-Info.plist → iOS (setelah Apple Developer aktif)
    • Service account JSON (Firebase Console → Project settings → Service accounts → Generate new private key)
  4. Set di server mpc-be:
    • FCM_PROJECT_ID = project id Firebase
    • FCM_CREDENTIALS_JSON = isi JSON service account (satu baris / escaped), atau
    • GOOGLE_APPLICATION_CREDENTIALS = path absolut ke file service account JSON di disk (bukan google-services.json). Contoh lokal: /Users/glen/Studios/KSR/mpc-be/mpclub-a3b1e-firebase-adminsdk-fbsvc-19b1a4f06c.json
  5. Apple (blokir iOS sampai selesai): enroll Apple Developer Program → APNs Auth Key (.p8) → upload ke Firebase Cloud Messaging. Lihat mpc-dev/docs/tasks.md.
  6. Web Push VAPID (Admin/Owner): Isi NEXT_PUBLIC_FIREBASE_VAPID_KEY di .env admin & owner dari Firebase Console → Project settings → Cloud Messaging → Web Push certificates → Generate key pair (pakai public key yang tampil).

Resend (email member web)

  1. Buat akun Resend, verifikasi domain pengirim.
  2. Set:
    • RESEND_API_KEY
    • EMAIL_FROM (contoh MPC <noreply@yourdomain.com>)
    • MEMBER_WEB_BASE_URL (link di body email, default https://mpc.example.com)

Env ringkas (mpc-be)

Lihat mpc-be/.env.example. Tanpa kredensial FCM/Resend, BE tetap jalan: inbox in-app ditulis; push/email di-skip (log warning).

POS register token (local)

flutter run --dart-define=ADMIN_API_KEY=local-dev-admin-key \
  --dart-define=MPC_BE_BASE=http://10.0.2.2:8080/api/v1

(emulator Android pakai 10.0.2.2 untuk host machine; device fisik pakai IP LAN.)