Push notifications reach iOS and Android through Firebase Cloud Messaging (FCM). The service never talks to a phone directly. It hands the message to Firebase, and Firebase delivers it using each device's token. This post covers how that call is made and what happens to bad tokens.
Where tokens come from
Device tokens arrive inside the Kafka event. The owning service attaches the user's active tokens when it publishes. People have more than one device, so an event often carries a list.
An event with no tokens isn't an error. The listener records the delivery status as SKIPPED and moves on.
Multicast: one call, many devices
For a list of tokens the service uses Firebase's multicast send. One call carries the message to every token, and the response reports success or failure per token, in request order. The service uses that to count successes and failures for each token, so metrics count devices that got the message, whatever the number of calls.…