Skip to content

feat(fcm): Enable fid and deprecate token for Send API#1211

Open
yvonnep165 wants to merge 3 commits into
mainfrom
yp-add-fid-arg
Open

feat(fcm): Enable fid and deprecate token for Send API#1211
yvonnep165 wants to merge 3 commits into
mainfrom
yp-add-fid-arg

Conversation

@yvonnep165
Copy link
Copy Markdown

This change deprecates token (in Message) and tokens (in MulticastMessage) as message targets, transitioning support to fid (Firebase Installation ID) and fids as the primary targets instead.

@yvonnep165 yvonnep165 added release-note release:stage Stage a release candidate labels May 21, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Firebase Installation IDs (FIDs) as message targets in the FCM SDK, deprecating registration token fields in favor of FIDs across the Message and MulticastMessage classes. Feedback indicates that the current implementation of MulticastMessage.getMessageList() fails to preserve the relative order of tokens and FIDs, which violates the API contract requiring response order to match the input order. Additionally, the class-level documentation for MulticastMessage needs to be updated to reflect the new combined limit of 500 for tokens and FIDs.

Comment on lines 80 to +98
List<Message> getMessageList() {
ImmutableList.Builder<Message> messages = ImmutableList.builder();

if (!this.tokens.isEmpty()) {
Message.Builder tokenBuilder = getMetadataBuilder();
for (String token : this.tokens) {
messages.add(tokenBuilder.setToken(token).build());
}
}

if (!this.fids.isEmpty()) {
Message.Builder fidBuilder = getMetadataBuilder();
for (String fid : this.fids) {
messages.add(fidBuilder.setFid(fid).build());
}
}

return messages.build();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current implementation of getMessageList() does not preserve the relative order of registration tokens and FIDs when both are present in a MulticastMessage. The class documentation and the sendEachForMulticast API contract specify that the order of responses in the BatchResponse must match the order in which targets were added to the message. However, the current logic groups all tokens first and then all FIDs.

To fix this, the MulticastMessage.Builder should maintain a single unified list of targets to track the exact sequence of additions, rather than storing them in separate tokens and fids builders.


@Deprecated
private final List<String> tokens;
private final List<String> fids;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The class-level Javadoc (specifically lines 33-35 and 41-44) should be updated to include references to FIDs. Currently, it only mentions "registration tokens" and states that the 500 limit applies to tokens, whereas the implementation now applies this limit to the combined total of tokens and FIDs.

Comment on lines +156 to +159
assertMessage(messages.get(0), "token1");
assertMessage(messages.get(1), "token2");
assertMessageFid(messages.get(2), "fid1");
assertMessageFid(messages.get(3), "fid2");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This test case confirms that the implementation does not preserve the relative order of targets. Even though tokens and FIDs are added in an interleaved manner (token1, fid1, token2, fid2), the test expects all tokens to appear before all FIDs. This behavior contradicts the API documentation regarding order preservation. The test should be updated to assert the actual addition order once the implementation is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:stage Stage a release candidate release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant