Push notifications
How the server sends them
- The server uses Firebase Cloud Messaging (Firebase Admin SDK, the project in
hrms-firebase-adminsdk.json) and sends to the raw FCM device token stored on the user. Expo push tokens would not work. - It stores one token per user (
UserEntity.FcmToken), set fromfcmTokenin login. Whichever device logged in last receives that user's pushes. - Every push is also saved in the user's notification inbox (Notifications), so the inbox is the source of truth.
Message format
{
"token": "<device FCM token>",
"notification": {
"title": "Leave Approved",
"body": "Your Casual Leave for 09-Nov-2026 has been approved."
},
"data": {}
}
The data object is always empty: a push does not say which record it is about. On tap, open the notification inbox and refresh it. The inbox rows carry pageName and referenceNo, which tell you which screen and record to open.
pageName → screen
pageName | Open | Record id |
|---|---|---|
leave-application | Leave request detail (S35) | referenceNo = leave application id |
thumb-application | Missed-punch / punch detail | punch (thumb application) id |
work-from-home | WFH request detail | WFH id |
over-time-application | Overtime request detail | overtime id |
clarification-application | Clarification detail | clarification id |
fuel-allowance-application | Fuel allowance detail | fuel allowance id |
compensation-application | Compensation detail | compensation id |
resign-application | Resignation detail | resignation id |
holiday-application | Holiday list (S36) | holiday entry id |
salary-report | Pay (S50) | — |
instruction-master | Announcements / instructions | instruction id |
request-module | Helpdesk request thread | request id |
employee-training-application | My trainings | training id |
Notification categories (category on the inbox row): LEAVE, THUMB, WORKFROMHOME, OVERTIME, CLARIFICATION, FUELALLOWANCE, COMPENSATION, RESIGN, HOLIDAY, SALARY, INSTRUCTION, REQUEST, TRAINING, BIRTHDAY, ANNIVERSARY, COMMON. Use them for the icon colour in the inbox (S70).
App checklist
- Request notification permission (Android 13+
POST_NOTIFICATIONS, iOS prompt). - Get the FCM token (
@react-native-firebase/messaging) and send it asfcmTokenon every login, including silent re-logins. - When the token refreshes (
onTokenRefresh), log in again silently (if biometrics are on) or on the next manual login. There is no endpoint that only updates the token. - On logout call
messaging().deleteToken()(there is no logout endpoint, see Logout). - On a tap, open the inbox and refresh it; from a row, use
pageName+referenceNo. - iOS needs an APNs key uploaded to the same Firebase project.