Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dry run #13

Merged
merged 3 commits into from
Jun 26, 2024
Merged

Dry run #13

merged 3 commits into from
Jun 26, 2024

Conversation

kimbauters
Copy link

The FCM v1 API supports a validate_only flag: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send . This is also known as a dry run in the Firebase Admin SDK. Messages that are sent with this flag enabled can effectively be used to test aspects such as network performance, while skipping the actual delivery of these messages to any devices.

This pull request adds the required field to the MessageWrapper, and introduces a new dry_run(...) function to the FcmClientBuilder to enable it. The default behaviour remains unchanged and will send messages through to devices. To use the dry run functionality you add dry_run(true):

let client = fcm::FcmClient::builder()
    ...
    .dry_run(true)
    .build()

The serialization is set up to skip the new field when it is set to false to ensure behaviour identical to the original implementation when dry_run(false) or when it is omitted.

@rj76
Copy link
Owner

rj76 commented Jun 26, 2024

Nice addition. Thanks! cargo fmt is failling though.

@kimbauters
Copy link
Author

Indeed, there was a formatting issue. Should be fixed now.

@rj76 rj76 merged commit 1f4d70c into rj76:main Jun 26, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants