-
Notifications
You must be signed in to change notification settings - Fork 20
Send Device Notifications
Redjan Ymeraj edited this page Mar 3, 2017
·
5 revisions
-
Get the FCM client from the container.
$fcmClient = $this->getContainer()->get('redjan_ym_fcm.client');
-
Create a Device Notification.
$notification = $fcmClient->createDeviceNotification( 'Title of Notification', 'Body of Notification', 'Firebase Token of the device who will recive the notification' );
In case you need to send extra data or set other notification properties the Notification Entity supports a set of setters and getters like:
$notification->setData($array); and $notification->getData(); $notification->setPriority('high'); // Excepts 2 priorities, high(default) and low $notification->setIcon('name of icon located in the native mobile app');
You could also modify the arguments passed in the
createDeviceNotification
method.$notification->setTitle('string'); $notification->setBody('text'); $notification->setDeviceToken('string');
The only required field is the Device Token
-
Send notification
$fcmClient->sendNotification($notification);
Go to Send Topic Notifications