Android: Messaging
Technical specification for in-app messaging in the PestControlOS Android app.
Data model
- Firestore: Conversations backed by Firestore. 1:1 chats use conversation IDs like
james_ian(ordered or hashed to ensure consistency). Sharedgroupconversation for team messages. - Documents: Message documents contain sender, text, timestamp, optional
urgentflag. Query by conversation ID; order by timestamp.
Retention
- Non-urgent: Messages can be auto-deleted after approximately 30 minutes. Implemented via Cloud Functions (scheduled or onWrite) or client-side TTL; optional.
- Urgent: Per-message flag to retain urgent messages; excluded from auto-deletion. Used for critical notifications that must remain in history.
Access control
- Firestore rules restrict read/write to participants of the conversation. Group conversation: all authenticated staff or role-based. Client only reads/writes conversations the user is allowed to see.
Integration
- Messaging screen shows conversation list and thread; unread indicators on home screen. Deep-link from in-app notification to messaging thread when notification references a message.