Skip to content

FR: Support for sending notification to multiple devices #277

Closed
@adihat

Description

@adihat

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions