FirebaseNotificationBundle
A Bundle for Symfony4 projects to send notifications for mobile devices through Firebase Cloud Messaging API, (*1)
Setup
Step 1: Download FirebaseNotificationBundle using composer
Add Firebase Notification in your composer.json:, (*2)
{
"require": {
"jp/firebase-notification-Bundle": "^2.0.0"
}
}
Now tell composer to download the bundle by running the command:, (*3)
``` bash
$ php composer.phar update "jp/firebase-notification-Bundle", (*4)
### Step 2: Enable the bundle
Enable the bundle in the kernel:
``` php
get('firebase_fcm_client');
?>
Example
Create message and send message
``` php
get('firebase_fcm_client');
$fcm->createMessage(array(
'to' => 'XXXXXXXX',
'title' => 'New message',
'body' => 'Hello World!',
'badge' => 1,
'data' => array(
'action' => "new_message"
)
));
$data = $fcm->sendMessage();
?>, (*5)
###Create topic message and send message
``` php
<?php
$fcm = $this->get('firebase_fcm_client');
$fcm->createMessage(array(
'topic' => '/topics/TOPIC_NAME',
'title' => 'New message',
'body' => 'Hello World!',
'badge' => 1,
'data' => array(
'action' => "new_message"
)
));
$data = $fcm->sendMessage();
?>