maximerenou/php-fcm

一个用于发送Firebase云消息和管理用户主题订阅、设备组和设备的库。

1.0.2 2019-05-16 12:00 UTC

This package is auto-updated.

Last update: 2024-09-16 23:32:51 UTC


README

一个用于发送Firebase云消息和管理用户主题订阅、设备组和设备的PHP库。

安装

使用composer安装

composer require maximerenou/php-fcm

关于这个分支

声音支持。

快速开始

// Instantiate the client with the project api_token and sender_id.
$client = new \Fcm\FcmClient($apiToken, $senderId);

// Instantiate the push notification request object.
$notification = new \Fcm\Push\Notification();

// Enhance the notification object with our custom options.
$notification
    ->addRecipient($deviceId)
    ->setTitle('Hello from php-fcm!')
    ->setBody('Notification body')
    ->setSound('custom_sound')
    ->addData('key', 'value');

// Send the notification to the Firebase servers for further handling.
$client->send($notification);

完整文档

请在此处阅读文档https://php-fcm.readthedocs.io/en/latest/或查看docs目录。

测试

使用PHPUnit运行单元测试

vendor/bin/phpunit -c phpunit.dist.xml

许可证

MIT