Pattern: Push notifications

Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.

Search terms: push notification, fcm, apns, notification permission, android 13 post_notifications, lock screen privacy, device token cleanup, localized notification

Last reviewed:

For agents

1. Problem

Ready-made sentences sent from the server fix the language, expose private text on the lock screen, and fail silently when the user turns permission off or the device token dies.

2. Options

Topic Option Upside Downside
Text Server sends finished text Simple One language per send; text is stored and logged server-side
Text Server sends type and variables; the app builds the text (recommended) Right language from the device; less private text in transit App must handle every type and have strings for each language
Delivery Via a middleman service Quick to start Extra party sees metadata; extra dependency
Delivery Directly via the platform services (FCM, APNs) Fewer parties; fewer moving parts Two integrations to maintain

4. Scenarios and edge cases

5. Common mistakes

6. How to audit

Sources