Yii2 Firebase Cloud Messaging适配器
v0.2.0
2016-11-11 13:22 UTC
Requires
- paragraph1/php-fcm: ^0.7
- yiisoft/yii2: ^2
This package is not auto-updated.
Last update: 2024-09-14 19:53:11 UTC
README
此组件封装了paragraph1/php-fcm库。
安装
推荐通过Composer安装
$ composer require understeam/yii2-fcm:~0.1 --prefer-dist
配置
将组件添加到您的应用程序配置中
... 'components' => [ 'fcm' => [ 'class' => 'understeam\fcm\Client', 'apiKey' => 'your API key', // Server API Key (you can get it here: https://firebase.google.com/docs/server/setup#prerequisites) ], ], ...
使用方法
更多使用示例请访问此处。
$note = Yii::$app->fcm->createNotification("test title", "testing body"); $note->setIcon('notification_icon_resource_name') ->setColor('#ffffff') ->setBadge(1); $message = Yii::$app->fcm->createMessage(); $message->addRecipient(new Device('your-device-token')); $message->setNotification($note) ->setData(['someId' => 111]); $response = Yii::$app->fcm->send($message); var_dump($response->getStatusCode());