Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR TEMPLATE
Description
Added Push Notification Service
Related Issues
Closed: #81

Please, there is a bug when running the backend
Changes Made - [ ]
How to Test
Backend Setup (backend/.env)
Add the credentials from your Service Account JSON:
env
Firebase Admin Credentials
FIREBASE_PROJECT_ID="your-project-id"
FIREBASE_CLIENT_EMAIL="your-service-account-email"
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"
Redis (Required for BullMQ Scheduling)
REDIS_HOST="localhost"
REDIS_PORT=6379
Frontend Setup (.env.local)
Add the Firebase Web Config:
env
NEXT_PUBLIC_FIREBASE_API_KEY="your-api-key"
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN="your-app.firebaseapp.com"
NEXT_PUBLIC_FIREBASE_PROJECT_ID="your-project-id"
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET="your-app.appspot.com"
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID="your-sender-id"
NEXT_PUBLIC_FIREBASE_APP_ID="your-app-id"
NEXT_PUBLIC_FIREBASE_VAPID_KEY="your-vapid-key"
Start Services: Ensure Redis is running, then start your backend (npm run start:dev) and frontend (npm run dev).
Login: Open the app in your browser and log in.
Enable Notifications:
Navigate to Settings (or /preferences).
Toggle Push Notifications to "On".
Verify Registration:
The browser will prompt for notification permission. Click Allow.
Check the browser's Network tab. You should see a successful POST request to /api/notifications/{userId}/device-tokens.
Check your database device_tokens table to see the new entry for your user.
You can trigger a notification by hitting the backend API. For testing, you can use a tool like Postman or curl.
Immediate Notification
bash
curl -X POST http://localhost:3000/api/notifications
-H "Content-Type: application/json"
-d '{
"userId": "your-user-uuid",
"title": "New Healthy Tip!",
"message": "Check out our new guide on pet nutrition.",
"category": "SYSTEM",
"metadata": {
"imageUrl": "https://example.com/pet-image.jpg"
}
}'
Scheduled Notification (Delayed)
To test the scheduling/BullMQ logic, add a scheduledFor date (ISO string):
bash
curl -X POST http://localhost:3000/api/notifications
-H "Content-Type: application/json"
-d '{
"userId": "your-user-uuid",
"title": "Reminder",
"message": "Scheduled checkup in 2 minutes.",
"category": "APPOINTMENT",
"scheduledFor": "2026-02-21T21:40:00.000Z"
}'
4. Verification
Foreground: If the app is open, you should see a browser notification (and a console log if you check developer tools).
Background: Close the app tab. Send the curl request. You should see a system-level push notification appear (handled by
firebase-messaging-sw.js
).
History: Go to the Notifications page (/notifications) in the app. The new notification should appear with its icon, rich description, and action button.
Action: Click "View Details" on a notification in the history list; it should redirect you to the actionUrl if provided.
Screenshots (if applicable)
Checklist