jp / firebase-notification-bundle
A Bundle for Symfony2 projects to send notifications for mobile devices through Firebase Cloud Messaging API
Installs: 10 829
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 2
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=5.6
- symfony/config: ^4.0
- symfony/dependency-injection: ^4.0
- symfony/framework-bundle: ^4.0
- symfony/http-foundation: ^4.0
- symfony/http-kernel: ^4.0
- symfony/options-resolver: ^4.0
- symfony/security: ^4.0
- symfony/validator: ^4.0
This package is auto-updated.
Last update: 2025-03-16 00:13:06 UTC
README
A Bundle for Symfony4 projects to send notifications for mobile devices through Firebase Cloud Messaging API
Setup
Step 1: Download FirebaseNotificationBundle using composer
Add Firebase Notification in your composer.json:
{ "require": { "jp/firebase-notification-Bundle": "^2.0.0" } }
Now tell composer to download the bundle by running the command:
$ php composer.phar update "jp/firebase-notification-Bundle"
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new JP\FirebaseNotificationBundle\JPFirebaseNotificationBundle() ); }
Step 3: Add configuration
# app/config/config.yml jp_firebase_notification: firebase_fcm: server_key: XXXXXX
Usage
Using service
<?php $fcm = $this->get('firebase_fcm_client'); ?>
##Example
###Create message and send message
<?php $fcm = $this->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(); ?>
###Create topic message and send message
<?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(); ?>