Overview
MechZie uses Firebase Cloud Messaging (FCM) for push notifications with Fast2SMS as an SMS fallback. All notifications are also stored in-app for retrieval via the API.Setting Up Push Notifications
Register FCM Token
On app startup and whenever the FCM token refreshes, register it with the API:Call this on every app launch. The server tracks
last_used_at and automatically prunes stale tokens. If you don’t re-register, the token may be cleaned up and the user will stop receiving push notifications.Listen for Token Refresh
Listing Notifications
Fetch in-app notifications (paginated):Marking as Read
Mark a single notification
Mark all as read
Notification Triggers
These events generate notifications for the relevant user:Customer Notifications
| Trigger | Title Example | When |
|---|---|---|
| Mechanic accepted job | ”Mechanic assigned” | Job status → accepted |
| Mechanic en route | ”Mechanic on the way” | Job status → en_route |
| Mechanic arrived | ”Mechanic has arrived” | Job status → arrived |
| Job completed | ”Service completed” | Job status → completed |
| Payment failed | ”Payment failed” | Razorpay payment.failed webhook |
| Refund processed | ”Refund issued” | Admin initiates refund (FCM + email) |
| No mechanic found | ”No mechanics available” | All dispatch tiers exhausted |
Mechanic Notifications
| Trigger | Title Example | When |
|---|---|---|
| New job offer | ”New job nearby” | Dispatch sends job:offer |
| Job cancelled by customer | ”Job cancelled” | Customer cancels |
| Verification approved | ”Profile verified” | Admin approves mechanic |
| Verification rejected | ”Verification update” | Admin rejects mechanic |
| Document review | ”Document reviewed” | Admin approves/rejects document |
Notification Data Payload
Thedata field contains structured data for deep-linking. Use it to navigate the user to the relevant screen:
Delivery Channels
| Channel | Priority | Notes |
|---|---|---|
| FCM Push | Primary | Requires registered token |
| Fast2SMS | Fallback | Used when FCM delivery fails |
| Email (Resend) | Specific events | Admin invites, refund confirmations |
| Socket.io | Real-time | job:status, payment:failed, etc. (see Real-time Events) |
| In-App | Persistent | Always stored in notifications table |
Push notifications and Socket.io events often carry the same information. Socket.io is for real-time UI updates while the user is active. Push notifications reach users when the app is in the background. In-app notifications serve as a persistent history.
Unread Badge Count
The API doesn’t have a dedicated unread count endpoint, but you can calculate it from the notification list:For a proper unread count, fetch the first page and count items where
is_read == false. Consider caching this and updating it when you mark notifications as read.