digitalap / fcmhttpbundle
一个通过HTTP协议将通知发送到移动设备的Google FCM工具包
1.0.0
2016-11-27 03:34 UTC
Requires
- php: >=5.5.9
- guzzlehttp/guzzle: ^6.2
This package is not auto-updated.
Last update: 2024-09-23 13:47:13 UTC
README
Symfony的Firebase云消息工具包
安装
通过composer
composer require digitalap/fcmhttpbundle
启用工具包
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new DigitalAp\FcmHttpBundle\FcmHttpBundle(), ); // ... } // ... }
配置
# app/config/config.yml fcm_http: autentication_api_key: keycode ....
用法
通知具有多个属性,请参阅FCM [文档] (https://firebase.google.com/docs/cloud-messaging/http-server-ref),您可以在FcmHttpBundle中找到它们的getter和setter。
//A MESSAGE MAY HAVE A NOTIFICATION OR NO $notification = new Notification('Text','Body'); $notification->enableSound(); //Put that one or more relations_id. Message expects an array as parameter //If it is greater than a thousand relations_ids the bundle will send the messages in a thousand $message = new Message(array( '0' '1' )); //A message may not have a notification or a data, but it must have one of the two. $message->setNotification($notification); $guzzle = $this->get('fcm_http.send')->send($message); // response for server dump(guzzle) //Each index of the array returned by the response means a lot of one thousand messages dump($guzzle[0]->getBody()->getContents());
此工具包使用了Guzzle php库
许可证 FcmHttpBundle遵循MIT许可证