Fcm Sender¶
Introduction¶
You have three methods available to send push notification:
sendTo($targets)to send downstream message.sendToTopic($topic)to send topic message.sendToGroup($group)to send group message.
Where:
$targetis a string or an array of devices’s tokens. (required)$topicis a topic or conditions of topics. (required)$groupis a group. (required)
Global¶
use Kerox\Fcm;
$fcm = new Fcm($apiKey);
$fcm->setNotification($notification)
->setData($data)
->setOptions($options);
Where:
$apiKeyis your FCM API key.$notificationcan be an NotificationBuilder object or an array containing the notification. (optional)$datacan be a DataBuilder object or an array with some data that will be passed. (optional)$optionscan be an OptionsBuilder object or an array of options for the payload. (optional)
If you passed arrays to setNotification(), setData(), or setOptions, their will be converted to builder object.
Downstream Message¶
$fcm->sendTo($target);
Topic Message¶
$fcm->sendToTopic($topic);
Group Message¶
$fcm->sendToGroup($group);
For more details on sending message, refer to the FCM documentation