php-fcm icon indicating copy to clipboard operation
php-fcm copied to clipboard

If you add more than five topics in FCM, the push doesn't send

Open AndyGaskell opened this issue 5 years ago • 0 comments

This is an odd one, but in FCM, if you add more than 5 topics, the message doesn't send.

This is really unhelpful in Firebase.

It's mentioned in the docs... https://firebase.google.com/docs/cloud-messaging/send-message

There is discussion about it at... https://stackoverflow.com/questions/44413037/how-to-send-fcm-push-notifications-to-multiple-topics

I was thinking we could throw an exception when a 6th topic is added.

At the very least we can mention this in the docs, in #39 Improve documentation

So, a 5 topic test ...

# set up the notification
$notification = new \Fcm\Push\Notification();

# send the push
$notification = $client->pushNotification($title, $body, "");
$notification->addTopic("mytopic_all");
$notification->addTopic("mytopic_nursery");
$notification->addTopic("mytopic_year1");
$notification->addTopic("mytopic_year2");
$notification->addTopic("mytopic_year3");
$response = $client->send($notification);

echo "response: ";
print_r($response);

Works fine, and returns...

response: Array
(
    [message_id] => 7035919789268175198
)

And a 6 topic / channel test ...

# set up the notification
$notification = new \Fcm\Push\Notification();

# send the push
$notification = $client->pushNotification($title, $body, "");
$notification->addTopic("mytopic_all");
$notification->addTopic("mytopic_nursery");
$notification->addTopic("mytopic_year1");
$notification->addTopic("mytopic_year2");
$notification->addTopic("mytopic_year3");
$notification->addTopic("mytopic_year4");
$response = $client->send($notification);

echo "response: ";
print_r($response);

Will not send the message to anyone, and returns...

response: Array
(
)

AndyGaskell avatar Oct 29 '20 11:10 AndyGaskell