docs: push notifications setup & env guide #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements browser push notifications for CodeNearby using Firebase Cloud Messaging (FCM). It includes:
Client-side: permission flow, token management, foreground handlers, and UI components to prompt users and manage notification preferences
Server-side: helper to send pushes with Firebase Admin, guarded initialization when credentials are missing, and API routes to persist tokens & settings
Integrations: wired notifications on friend requests, gathering chat, and direct messages; guarded database/firebase usage to avoid startup crashes when envs are missing
Actions for the author / maintainer (priority order)
-Provide secrets for real testing
-Add Firebase client vars to environment for the deployment
-Add Firebase Admin credentials: FIREBASE_PROJECT_ID, FIREBASE_CLIENT_EMAIL, FIREBASE_PRIVATE_KEY (replace newlines with \n when pasting into env).
-Ensure MONGODB_URI points to a running DB.
-Service worker config (required)
-Replace the placeholders in [firebase-messaging-sw.js] with real Firebase client config at build time, or add a build script that generates [firebase-messaging-sw.js] from NEXT_PUBLIC_* env vars (I can implement this if you want).
-Validate end-to-end flow locally
Run: npm run dev
-Sign in, go to Profile → Edit → Notifications, enable permissions.
-From another account or via app flows, trigger:
Direct message to a user
Friend request
Gathering chat message
Verify notifications appear in foreground and background and that notification clicks navigate correctly.
Security & review
Confirm no secrets were committed (PR contains placeholders only).
Review server send logic in lib/push-notifications-server.ts for payload shape & error handling.
Optionally run a linter/TS check: npm run lint / npm run build.