APIs & services / Firebase

Receive endorsement and broadcast push messages.

Endpointtoday's app
Call
SDK FCM topic subscribe: urvi_endorsement_status, urvi_endorsement_comment, NOTIFICATION
Service
Firebase
Features
Notifications, VO / SHG / Farmer endorsement
When
After login
Auth
Firebase app credentials
In the App Service

Use case

On every HomeActivity open (non-Vrutti tenants), AppUtils.subscribeTopics subscribes the device to three FCM topics: urvi_endorsement_status, urvi_endorsement_comment and NOTIFICATION. unsubscribeTopic() removes them. FirebaseMessageReceiver handles data messages. Status and comment messages look up the farmer by key_entity_id and show a local notification unless the logged-in user is the sender. Any other topic shows title and body and saves them to the notifications table. The publishers are the app itself: EndorsementPostRH and EndorsementCommentPostRH call FcmUtil.sendMessage, which POSTs to the legacy https://fcm.googleapis.com/fcm/send with "Authorization: key=<FCM server key>". That server key comes from app constants (AppUtils.getAppConstant().getFCMServerkey()), so it is shipped to every device. Google retired the legacy FCM API in 2024, so these device-originated sends probably fail silently. onNewToken does nothing (the token is never registered with the backend).

Headers

HeaderValueNotes
Authorization (device-side legacy FCM send)key=<redacted: FCM server key fetched from app constants, see ApplicationClass.kt:64 / HomeViewModel.kt:147>Secret leak: the server key is held on the device and sent from it.
Content-Typeapplication/jsonLegacy send only.

Parameters

ParamInRequiredExampleNotes
topicpathYesurvi_endorsement_statusOne of urvi_endorsement_status, urvi_endorsement_comment, NOTIFICATION. Global topics: every device of every user on the tenant gets every message.

Request

Example request body (synthetic data)
{
  "to": "/topics/urvi_endorsement_status",
  "data": {
    "key_entity_id": "440012",
    "key_member_name": "SHG A",
    "key_current_entity_status": "ENDORSED",
    "key_user_id": "1001",
    "key_endorsed_user_name": "Cadre A",
    "key_entity_type": "ENTITY.TYPE.SHG",
    "key_entity_reviewed_by": "null"
  }
}
FieldTypeRequiredNotes
tostringYes/topics/urvi_endorsement_status or /topics/urvi_endorsement_comment.
data.key_entity_id / key_entity_typestringYesEndorsed entity.
data.key_member_name, key_current_entity_status, key_user_id, key_endorsed_user_name, key_entity_reviewed_bystringNoStatus messages. PII: names and user ids broadcast to all subscribers.
data.key_comment_description, key_comment_posted_bystringNoComment messages. PII: comment text broadcast to all subscribers.

Response

Example response body (synthetic data)
{
  "NOTIFICATION topic message": {
    "data": {
      "title": "Data download scheduled",
      "body": "Please keep the app open tonight."
    }
  }
}
FieldTypeRequiredNotes
fromstringTopic used to route the message.
data.key_entity_idstringLooked up with getIeFlatFromOltpId. No notification if not found locally.
data.key_current_entity_status / key_entity_reviewed_by / key_user_idstringUsed to suppress self-notifications (FOR_REVIEW compares reviewer, others compare endorser).
data.key_comment_posted_bystringCompared with the user's first name to suppress self-notifications.
data.title / data.bodystringNOTIFICATION topic: shown and saved to the notifications DB.

Errors

StatusWhenWhat the app does
SDK / HTTP failureSubscribe fails or legacy send rejectedLogged only.

Source

  • app/src/main/java/org/platformcommons/urvi/utility/AppUtils.kt
  • app/src/main/java/org/platformcommons/urvi/fcm/FirebaseMessageReceiver.kt
  • app/src/main/java/org/platformcommons/urvi/vo/AppConstants.kt
  • app/src/main/java/org/platformcommons/urvi/view/home/HomeActivity.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/fcm/FcmUtil.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/fcm/FCMConstant.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/sync/rh/EndorsementPostRH.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/sync/rh/EndorsementCommentPostRH.kt
  • app/src/main/java/org/platformcommons/urvi/core/ApplicationClass.kt