2

I run tihs code:

cred = credentials.Certificate('x.json')
firebase_admin.initialize_app(cred)
registration_tokens = [
    'GET REAL TOKEN1',
    'GET REAL TOKEN2',
]

message = messaging.MulticastMessage(
    notification=messaging.Notification(
        title="Notification Title",
        body="Notification Text",
    ),
    tokens=registration_tokens
)

response = messaging.send_multicast(message)
print('response', response.success_count, response.failure_count)

when run this code get error:

<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/batch</code> was not found on this server.  <ins>That’s all we know.</ins>

NOTE: I can send message to one user and work correctly:

messaging.Message()

2 Answers 2

3

Multicast messaging is no longer supported in Firebase Cloud Messaging. While your SDK version may still have a method for it, the endpoint that that method calls has been removed.

From the Firebase documentation on sending messages to multiple devices:

Important: The send methods described in this section were deprecated on June 21, 2023, and will be removed in June 2024. For protocol, instead use the standard HTTP v1 API send method, implementing your own batch send by iterating through the list of recipients and sending to each recipient's token. For Admin SDK methods, make sure to update to the next major version. See the Firebase FAQ for more information.

I recommend upgrading to the latest version of the SDK you use, and checking what method most closely matches your needs there.

This has been posted multiple times in the past week, so I recommend searching for relevant posts. One such post:

Sign up to request clarification or add additional context in comments.

Comments

0

You can use messaging.send_each_for_multicast(message) instead of send_multicast(message). This sends the message to each device individually and handles failures per device.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.