Skip to content

Conversation

@soumya813
Copy link

@soumya813 soumya813 commented Sep 4, 2025

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.

@vercel
Copy link

vercel bot commented Sep 4, 2025

@soumya813 is attempting to deploy a commit to the Subhadip Saha's projects Team on Vercel.

A member of the Team first needs to authorize it.

@soumya813 soumya813 marked this pull request as ready for review September 4, 2025 06:06
@vercel
Copy link

vercel bot commented Sep 6, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
code-nearby Error Error Sep 6, 2025 8:12pm

@subh05sus
Copy link
Owner

Please Fix

./components/notification-settings.tsx
49:6 Warning: React Hook useEffect has a missing dependency: 'loadSettings'. Either include it or remove the dependency array. react-hooks/exhaustive-deps
295:30 Error: ' can be escaped with ', ‘, ', ’. react/no-unescaped-entities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants