feat(fcm): Enable fid and deprecate token for Send API#3145
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for Firebase Installation IDs (FIDs) in the messaging service by adding the FidMessage interface and updating the Message union type. The MulticastMessage interface now supports targeting via fids, and the tokens field has been deprecated and made optional. Feedback includes suggestions to add documentation for the new FidMessage interface, refactor the message construction logic using object destructuring for better maintainability, and improve the grammar of validation error messages. Additionally, the reviewer noted that making tokens optional is a breaking change for TypeScript consumers that should be highlighted in release notes.
| export interface MulticastMessage extends BaseMessage { | ||
| tokens: string[]; | ||
| /** | ||
| * A list of Firebase Installation IDs (FIDs) to target. | ||
| */ | ||
| fids?: string[]; | ||
|
|
||
| /** | ||
| * A list of registration tokens to target. | ||
| * | ||
| * @deprecated Use {@link MulticastMessage.fids} instead. | ||
| */ | ||
| tokens?: string[]; | ||
| } |
There was a problem hiding this comment.
Changing tokens from a required field (tokens: string[]) to an optional one (tokens?: string[]) in the MulticastMessage interface is a breaking change for TypeScript consumers who might be relying on the property's presence (e.g., accessing .length without a null check). While necessary for the migration to fids, this should be clearly highlighted in the release notes.
…or the messages array construction in MulticastMessage
This change deprecates
TokenMessageinterface and thetokensfield inMulticastMessageinterface as message targets, transitioning support toFidMessageinterface andfidsinMulticastMessageas the primary targets instead.The multicast helper function
sendEachForMulticastis updated to support both target types concurrently up to a combined total of 500.