Skip to content

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

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

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

Conversation

@yvonnep165

@yvonnep165 yvonnep165 commented Jun 5, 2026

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.

Legacy token tests are wrapped in Method-Level #pragma warning disable CS0618 to prevent compiler warnings and build crash and #pragma wrappers are explicitly maintained for snippet documentation code to allow compiling flawlessly.

@yvonnep165 yvonnep165 self-assigned this Jun 5, 2026
@yvonnep165 yvonnep165 added release-note release:stage Stage a release candidate labels Jun 5, 2026

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

Copy link
Copy Markdown

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) in Firebase Cloud Messaging (FCM) by adding the Fid property to Message and the Fids property to MulticastMessage, while deprecating the older Token and Tokens properties. It updates validation, copying, and serialization logic to support these new fields, adds comprehensive unit and integration tests, and suppresses deprecation warnings where necessary. The review feedback suggests improving consistency in exception messages by capitalizing property names (Tokens and Fids) and ensuring proper punctuation.

Comment thread FirebaseAdmin/FirebaseAdmin/Messaging/MulticastMessage.cs Outdated
Comment thread FirebaseAdmin/FirebaseAdmin/Messaging/MulticastMessage.cs Outdated

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.

Shall we update the comments for SendEachForMulticastAsync to mention the message response order in BatchResponse when both Tokens and FIDs are set in MulticastMessage?

@yvonnep165 yvonnep165 Jun 8, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure! Updated comments for both SendEachForMulticastAsync and SendMulticastAsync

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.

Could we update this test file to include some tests using fid messages?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

MessageTest.cs is already handling the payload serialization/deserialization logic for FIDs. FirebaseMessagingClientTest.cs is responsible for testing the HTTP transport layer. It typically uses a generic Topic or Token payload just as a dummy placeholder to verify that the HTTP request is built correctly. Since we already have full FID coverage in MessageTest.cs and the FirebaseMessagingTest.cs integration tests, it seems a bit redundant to add some tests using fid messages in FirebaseMessagingClientTest.cs. But please let me know if you'd still prefer I add a dummy FID payload test there for completeness!

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.

If we prefer not to add new tests, it would also be nice to simply replace the Token payload with the FID payload as a dummy placeholder. Since the Token payload is deprecated, this would also avoid the #pragma warning. Additionally, this covers testing the integration with the FID payload.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sounds good! I have replaced the Token payload with the FID one. Thanks for the detailed review!

#pragma warning disable CS0618
Token = deviceToken,
#pragma warning restore CS0618
Notification = new Notification()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add extend the code snippet to show the new usage with Fids?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure! Code snippets for the new usage with Fids are added.

{
return @"{
""error"": {
""status"": ""INVALID_ARGUMENT"",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the reason for removing the INVALID_ARGUMENT error code? I think it is good to verify that a 400 Bad Request with INVALID_ARGUMENT error converts to MessagingErrorCode.Unregistered (for tokens) unless the recent fix changes that for tokens as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I was doing a complete replacement from Token to Fid in this file but you're right, it's good to verify the bad request for tokens. I have added them back.

@yvonnep165

Copy link
Copy Markdown
Author

/gemini review

@yvonnep165 yvonnep165 requested a review from OrlandriaH-G June 11, 2026 21:13

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

Copy link
Copy Markdown

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) in Firebase Cloud Messaging (FCM) by adding Fid to Message and Fids to MulticastMessage, while deprecating the older Token and Tokens properties. It updates validation, serialization, and multicast sending logic to support up to 500 combined targets, alongside adding corresponding tests and snippets. However, several critical syntax errors were identified in FirebaseMessagingClientTest.cs where trailing commas were mistakenly appended to #pragma warning restore CS0618 preprocessor directives, which will cause compilation failures.

Comment thread FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingClientTest.cs Outdated
Comment thread FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingClientTest.cs Outdated
Comment thread FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingClientTest.cs Outdated
Comment thread FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingClientTest.cs Outdated
Comment thread FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingClientTest.cs Outdated
Comment thread FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingClientTest.cs Outdated
Comment thread FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingClientTest.cs Outdated
Comment thread FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingClientTest.cs Outdated
Comment thread FirebaseAdmin/FirebaseAdmin/Messaging/Message.cs Outdated
Comment thread FirebaseAdmin/FirebaseAdmin/Messaging/MulticastMessage.cs Outdated
Comment thread FirebaseAdmin/FirebaseAdmin/Messaging/MulticastMessage.cs Outdated
yvonnep165 and others added 3 commits June 12, 2026 10:38
Co-authored-by: OrlandriaC-G <112568492+OrlandriaH-G@users.noreply.github.com>
Co-authored-by: OrlandriaC-G <112568492+OrlandriaH-G@users.noreply.github.com>
Co-authored-by: OrlandriaC-G <112568492+OrlandriaH-G@users.noreply.github.com>
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.

4 participants