jp/firebase-notification-bundle
Composer 安装命令:
composer require jp/firebase-notification-bundle
包简介
A Bundle for Symfony2 projects to send notifications for mobile devices through Firebase Cloud Messaging API
README 文档
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(); ?>
统计信息
- 总下载量: 10.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-01