Edujugon / PushNotification

PHP and Laravel Package to send push notifications to Android and IOS devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

send() does not work for topics (without deviceTokens)

olga2323 opened this issue · comments

It is not possible to call send() without deviceToken(s) set. The deviceToken(s) are not necessary when sending to topics though.

Hi @olga2323 ,

the last version of the package supports sending messages by topic.

This is an example about how use it:

$push = new PushNotification('fcm');
$response = $push->setMessage(['message'=>'Hello World'])
            ->setApiKey('YOUR-API-KEY')
            ->setConfig(['dry_run' => false])
            ->sendByTopic('dogs')
            ->getFeedback();

or with a condition:

$push = new PushNotification('fcm');
$response = $push->setMessage(['message'=>'Hello World'])
            ->setApiKey('YOUR-API-KEY')
            ->setConfig(['dry_run' => false])
            ->sendByTopic("'dogs' in topics || 'cats' in topics",true)
            ->getFeedback();

Give it a try and let me know if that solved your issue.