Skip to main content

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 from fcmToken in 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​

pageNameOpenRecord id
leave-applicationLeave request detail (S35)referenceNo = leave application id
thumb-applicationMissed-punch / punch detailpunch (thumb application) id
work-from-homeWFH request detailWFH id
over-time-applicationOvertime request detailovertime id
clarification-applicationClarification detailclarification id
fuel-allowance-applicationFuel allowance detailfuel allowance id
compensation-applicationCompensation detailcompensation id
resign-applicationResignation detailresignation id
holiday-applicationHoliday list (S36)holiday entry id
salary-reportPay (S50)—
instruction-masterAnnouncements / instructionsinstruction id
request-moduleHelpdesk request threadrequest id
employee-training-applicationMy trainingstraining 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​

  1. Request notification permission (Android 13+ POST_NOTIFICATIONS, iOS prompt).
  2. Get the FCM token (@react-native-firebase/messaging) and send it as fcmToken on every login, including silent re-logins.
  3. 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.
  4. On logout call messaging().deleteToken() (there is no logout endpoint, see Logout).
  5. On a tap, open the inbox and refresh it; from a row, use pageName + referenceNo.
  6. iOS needs an APNs key uploaded to the same Firebase project.