firebase-admin-python
firebase-admin-python copied to clipboard
FR: Support for sending notification to multiple devices
Currently there is support to send notifications to specific devices as documented here.
There is support for sending notifications to multiple devices in Node JS SDK and Java SDK.
Example:
const registrationTokens = [
'YOUR_REGISTRATION_TOKEN_1',
// …
'YOUR_REGISTRATION_TOKEN_N',
];
const message = {
data: {score: '850', time: '2:45'},
tokens: registrationTokens,
}
admin.messaging().sendMulticast(message)
.then((response) => {
console.log(response.successCount + ' messages were sent successfully');
This operation uses the sendAll() API under the hood and return value is a BatchResponse.
It would be good if there was something similar in python sdk:
registration_tokens = [
'YOUR_REGISTRATION_TOKEN_1',
// …
'YOUR_REGISTRATION_TOKEN_N',
]
message = messaging.Message(
data={
'score': '850',
'time': '2:45',
},
tokens=registration_tokens,
)
response = messaging.send_multicast(message)
print(f"{response['successCount']} messages were sent successfully")
Unless I missed something, this issue was fixed by #283 and can be closed.
It would be nice to have a PyPI release with this feature :-) Thank you :-)
Release on its way.