I use Firebase to send notifications to multiple devices that have subscribed to a particular topic.
To send a notification to a combination of topics, I use "conditions" as described below:
String condition = "'TopicA' in topics && ('TopicB' in topics || 'TopicC' in topics || 'TopicD' in topics || 'TopicE' in topics) && ('TopicF' in topics || 'TopicG' in topics)"
Message message = Message.builder()
.setNotification(Notification.builder()
.setTitle("notificationTitle")
.setBody("notification body bla bla")
.build())
.setCondition(condition)
firebaseService.send(message)
This works fine if the condition contains only 5 topics, otherwise I get an error:
HTTP Error: 400, Request contains an invalid argument.
as I understand it is a bug in FCM, which is still not resolved
I found a workaround here : https://stackoverflow.com/a/52302136/4774302, which consists in breaking a condition into several conditions.
Is there an automated way to break the condition into a group of 5, with a minimum of firebase requests ?