firebase-admin-python
firebase-admin-python copied to clipboard
[FR] messaging.send_all SendResponse should include the device token
Is your feature request related to a problem? Please describe.
Using send_all (or send_multicast) is (or should be) more efficient that many send calls in sequence. However, it loses the ability to identify which tokens failed to send. We need to know which token failed so we can unregister these in our backend (as recommended by Best practices for FCM registration token management). Example:
batch_response = messaging.send_all(...)
for response in batch_response.responses:
if not response.success:
if isinstance(response.exception, messaging.UnregisteredError):
# We want the token for this particular response here so we can delete it from the backend.
else:
raise response.exception
Describe the solution you'd like
The SendResponse class should have a token field.
Describe alternatives you've considered
The documentation doesn't mention if the order of responses matches that of the tokens argument to MulticastMessage. If that was the case we could figure out what token was used. However, from reading the code these two arrays don't have elements in the same order (which isn't unexpected given the concurrent nature of the HTTP requests involved).
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.