Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send to all users with a specific language in Firebase Messaging

In the Firebase Console it is possible to target devices using a specific app, language, version and user properties. Is it somehow possible to do the same with the API? Or is creating topics the only way to solve bulk sending notifications?

Basically what I would like to do is send a notification to all users with a specific language. I would use the console, but I need to set a click_action / category and that's not supported in the console (as far as I know).

like image 690
Johan Nordberg Avatar asked Oct 18 '22 08:10

Johan Nordberg


1 Answers

There is no way within the API to select devices that match arbitrary criteria. You will have to figure out how to select the appropriate devices yourself. You have two options

One strategy might be to use topics that match the languages that you might wish to target. Client apps can subscribe to the topics that match their language preferences, and you can broadcast a message to them via those topics.

Another strategy might be to store language preferences for each user/device in your database (along with the device's token), then query for users/devices who have that language preference. Once you've collected all the tokens for the matching devices, you can send a message using only those tokens.

like image 186
Doug Stevenson Avatar answered Oct 21 '22 02:10

Doug Stevenson