-
Notifications
You must be signed in to change notification settings - Fork 20
Send Device Notifications
Redjan Ymeraj edited this page Jan 27, 2025
·
6 revisions
-
Get the FCM client from the container.
$fcmClient = $this->getContainer()->get('redjan_ym_fcm.client');
-
Create a Device Notification.
use RedjanYm\FCM\Notification; use RedjanYm\FCM\Recipient\Device; $testToken = 'this-is-a-token'; $recipient = new Device($testToken); $notification = new Notification($recipient, 'Title', 'Body', ['key' => 'value']); $fcmClient->send($notification);
In case you need to set other notification properties the Notification class supports many public properties like:
$notification->priority = 'high'; // Excepts 2 priorities, high(default) and low $notification->icon = 'name of icon located in the native mobile app'; // And many more
-
Send notification
$fcmClient->sendNotification($notification);