firebase-admin-python icon indicating copy to clipboard operation
firebase-admin-python copied to clipboard

FR: Support for sending notification to multiple devices

Open adihat opened this issue 7 years ago • 2 comments

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")

adihat avatar Mar 28 '19 20:03 adihat

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 :-)

aaugustin avatar May 23 '19 09:05 aaugustin

Release on its way.

hiranya911 avatar May 23 '19 17:05 hiranya911