代码拉取完成,页面将自动刷新
PHP application server implementation for Firebase Cloud Messaging.
#Setup The recommended way of installing is using Composer.
command line
composer require paragraph2/php-fcm
composer.json
"require": {
"paragraph2/php-fcm": "*"
}
#Send to Device also see https://firebase.google.com/docs/cloud-messaging/downstream
use paragraph2\phpFCM\Client;
use paragraph2\phpFCM\Message;
use paragraph2\phpFCM\Recipient\Device;
use paragraph2\phpFCM\Notification;
require_once 'vendor/autoload.php';
$apiKey = 'YOUR SERVER KEY';
$client = new Client();
$client->setApiKey($apiKey);
$client->injectHttpClient(new \GuzzleHttp\Client());
$note = new Notification('test title', 'testing body');
$note->setIcon('notification_icon_resource_name')
->setColor('#ffffff')
->setBadge(1);
$message = new Message();
$message->addRecipient(new Device('your-device-token'));
$message->setNotification($note)
->setData(array('someId' => 111));
$response = $client->send($message);
var_dump($response->getStatusCode());
#Send to topic also see https://firebase.google.com/docs/cloud-messaging/topic-messaging
use paragraph2\phpFCM\Client;
use paragraph2\phpFCM\Message;
use paragraph2\phpFCM\Recipient\Topic;
use paragraph2\phpFCM\Notification;
require_once 'vendor/autoload.php';
$apiKey = 'YOUR SERVER KEY';
$client = new Client();
$client->setApiKey($apiKey);
$client->injectHttpClient(new \GuzzleHttp\Client());
$message = new Message();
$message->addRecipient(new Topic('your-topic'));
$message->setNotification(new Notification('test title', 'testing body'))
->setData(array('someId' => 111));
$response = $client->send($message);
var_dump($response->getStatusCode());
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。