firebase / firebase-admin-dotnet

Firebase Admin .NET SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
357 stars 129 forks source link

feat(fcm): Implement `SendEachAsync` and `SendEachForMulticastAsync` #343

Closed Doris-Ge closed 1 year ago

Doris-Ge commented 1 year ago

SendEachAsync vs SendAllAsync

  1. SendEachAsync sends one HTTP request to V1 Send endpoint for each message in the list. SendAllAsync sends only one HTTP request to V1 Batch Send endpoint to send all messages in the list.
  2. SendEachAsync calls Task.WhenAll to wait for all httpClient.SendAndDeserializeAsync calls to complete and construct a BatchResponse with all SendResponses. An httpClient.SendAndDeserializeAsync call to V1 Send endpoint either completes with a success or throws an exception. So if an exception is thrown out, the exception will be caught in SendEachAsync and turned into a SendResponse with an exception. Therefore, unlike SendAllAsync, SendEachAsync does not always throw an exception for a total failure. It can also return a BatchResponse with only exceptions in it.

SendEachForMulticastAsync calls SendEachAsync under the hood.