Provider-Side Deduplication
What you'll learn: How to offload notification deduplication to external providers like FCM and APNs using built-in collapse mechanisms.
Why Offload Deduplication?
After implementing your own idempotency keys and deduplication windows, you might wonder: "Do I have to do all this work?" The good news: many notification providers already handle deduplication for you—if you know how to use their features.
FCM's collapse_key
Firebase Cloud Messaging (FCM) lets you tag notifications with a collapse_key. When multiple notifications with the same collapse key arrive while the device is offline, only the latest one is delivered when it reconnects.
Analogy: It's like leaving sticky notes on someone's desk. If you write "Meeting at 3pm" and later update it to "Meeting at 4pm" with the same label "meeting-reminder," they'll only see the final note when they return.
Message 1: collapse_key="score-update", body="Score: 1-0"
Message 2: collapse_key="score-update", body="Score: 2-1" (replaces Message 1)
APNs' apns-collapse-id
Apple Push Notification service (APNs) provides apns-collapse-id with identical behavior. Multiple notifications with the same collapse ID get deduplicated automatically, keeping only the most recent.
When to Use Provider-Side Deduplication
- Rapid updates: Score updates, status changes, progress bars
- Device offline scenarios: User reconnects after hours—sees only final state
- Reducing notification fatigue: Prevents spam from transient states
Key Takeaway: Leverage provider features like FCM's collapse_key and APNs' apns-collapse-id to deduplicate at the edge, reducing server-side complexity and ensuring users see only the most relevant notification when devices reconnect.