Designing Multi-Device Push Notifications with Flutter and FirestoreDesigning Multi-Device Push Notifications with Flutter and Firestore
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
A push notification model usually breaks in one of two ways: a second phone stops receiving anything, or notifications keep arriving for the account that just signed out. Both come from storing one push address per user. Store one row per app installation instead, with the user ID as a field, and someone with a phone and a tablet has two rows that a single query returns.
The sign-out half has an ordering trap. Delete the installation row while the user is still signed in, then call signOut. A security rule that compares the row owner to the signed-in user refuses the delete once there is no user left to compare against, and the device keeps pointing at the previous account.
The full write-up covers the Firestore rules, the Flutter registration listener, a server cleanup that handles both unregistered error codes, and an acceptance sequence to run on two test installations.

duskolicanin.com

Keep Flutter Push Tokens Correct Across Devices

Fix Flutter push notifications that miss a second device or follow the previous user: store one FCM installation ID per device and prune unregistered IDs.

Fatima's avatar
Great breakdown! The sign-out timing is such an easy detail to overlook, but it can cause real issues. 👏
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started