Firebase Send a message to multiple topics

I am trying to send cloud messages to users who subscribe to several topics through an API call (POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send ) with the following authority:

{ headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer MY_ACCESS_TOKEN` }, body: { "message": { "condition": "'cat' in topics || 'dog' in topics", "notification": { "title": "Message Title", "body": "Message Body" } } } } 

I wrote this configuration in accordance with the FCM documentation . I can get an answer like this:

 { "name": "projects/myproject-b5ae1/messages/5735743068807585451" } 

but no devices received messages.

I used an access token for other APIs that works. I also know that the FCM documentation also provided another authority for the cURL request, which I also tried but did not work.

It’s strange if I provide only one subject in condition , the message is really successfully sent to devices with a subscription. Am I writing something wrong?

I already referred to other solutions in Stackoverflow, but still not working:

Firebase API with multiple themes in state

How to send FCM Push alerts on multiple topics

0
source share
1 answer

After talking with Firebase Support, they pointed out a problem that I encountered, this is a known bug that they are still trying to fix. And there is still no specific timeline for correction.

Therefore, there is no problem with my code, and I will have to figure out the workaround myself if I really want to use the "||" operator (OR).

My current workaround is to track subscribers with the database (since Firebase does not offer subscribers), and then fulfill the OR condition yourself, finding a pool of subscribers on different topics.

enter image description here

PS I just don’t understand why downvotes, I really found an error here and referred to all the solutions that I could find on SO before asking a question here.

+1
source

Source: https://habr.com/ru/post/1263190/


All Articles