Push notifications
setup and sending.
Firebase Cloud Messaging setup for Android and iOS. The console sends scheduled campaigns to segments with a copy in each user's inbox. One-off sends to every device still go to the FCM topic all.
01How it works
Notifications are on by default. While they are on in the app settings, the app asks for permission and subscribes to the topic all; when the user switches them off, it unsubscribes (app/lib/main.dart).
The app also sends its push token to the server with reportDevice, which stores it on the user's device record (users/{uid}/devices/{hash}.fcmToken). That is what campaigns use:
- Campaigns (console → Push campaigns → Schedule campaign) go to a segment (everyone, VIP, inactive for 7 days, new users, minimum level, or the members of one team) at a set time, through the job
sendPushCampaigns, and leave a copy in each user's inbox. Details: Push campaigns. - Send now to everyone sends one message to the topic
allright away, without an inbox copy.
Firebase Cloud Messaging is on by default in every Firebase project. Android needs nothing more (the POST_NOTIFICATIONS permission is already in AndroidManifest.xml).
02iOS setup
- APNs keyApple Developer → Certificates, IDs & Profiles → Keys → create a key with Apple Push Notifications service. Upload it in Firebase console → Project settings → Cloud Messaging → Apple app configuration.
- CapabilitiesIn Xcode, Runner target → Signing & Capabilities: add Push Notifications and Background Modes → Remote notifications. The package ships no entitlements file; Xcode creates it.
These are the standard FlutterFire messaging steps; follow Firebase's current guide if Apple's screens have changed.
03Send a notification
- DefaultsOptional: console → Push defaults → default title and message.
- ComposeConsole → Push campaigns. Title (up to 65 characters) and message (up to 240). Managers and owners only; every action is recorded in the audit log.
- Schedule or sendSchedule campaign for a segment (for a team, pick it in the Team field) and time, or Send now to everyone.
Store policies treat spammy or misleading notifications as a violation. Never imply that users can win or earn money.