Android Notifications
Priority: P2 (OPTIONAL)
Implementation Guidelines
- Channels: Create
NotificationChannelwith unique ID (required for API 26+). Notifications without valid channel silently dropped. UseNotificationCompatfor backwards compatibility. - Permissions: Explicitly request
POST_NOTIFICATIONSon Android 13+ (API 33). Avoid requesting system permission on app launch; show priming dialog first to explain benefit. - Service: Implement
FirebaseMessagingServicewithonMessageReceivedandonNewTokenfor background push handling. Declare service inAndroidManifestwithMESSAGING_EVENTintent action. - Flow: Handle notification taps in both
onCreateandonNewIntentusingPendingIntent. Pass data between activities viaIntentextras. - Payload: Limit notification payload to essential IDs. Perform background data fetching via WorkManager if more data needed.
Anti-Patterns
- No Missing Channel: Notifications fail silently without channels on API 26+.
- No Unconditional Requests: Don't spam permission dialog on first launch.
- No Missing Manifest: Service must declared with
MESSAGING_EVENTaction.