kedniko/firebase-cloud-messaging-http-v1-php
最新稳定版本:v0.0.2
Composer 安装命令:
composer require kedniko/firebase-cloud-messaging-http-v1-php
包简介
Firebase cloud messaging http v1 php
关键字:
README 文档
README
Firebase Cloud Messaging Http v1 for PHP
Installation
composer require kedniko/firebase-cloud-messaging-http-v1-php
Send a message
<?php $authKeyContent = json_decode(file_get_contents(__DIR__ . '/appname-30xfgre76.json'), true); $projectID = 'my-project-1'; $body = [ 'message' => [ 'token' => '<token:string>', 'notification' => [ 'title' => 'Breaking News', 'body' => 'New news story available.', ], 'data' => [ 'story_id' => 'story_12345', ], ], ]; $bearerToken = FCM::getBearerToken($authKeyContent); FCM::send($bearerToken, $projectID, $body);
Send multiple messages
<?php $authKeyContent = json_decode(file_get_contents(__DIR__ . '/appname-30xfgre76.json'), true); $projectID = 'my-project-1'; $tokens = [ '<token1:string>', '<token2:string>', '<token3:string>', ]; $bearerToken = FCM::getBearerToken($authKeyContent); foreach ($tokens as $token) { $body = [ 'message' => [ 'token' => $token, 'notification' => [ 'title' => 'Breaking News', 'body' => 'New news story available.', ], 'data' => [ 'story_id' => 'story_12345', ], ], ]; FCM::send($bearerToken, $projectID, $body); }
Subscribe to topic
<?php $authKeyContent = json_decode(file_get_contents(__DIR__ . '/appname-30xfgre76.json'), true); $tokens = [ '<token1:string>', '<token2:string>', '<token3:string>', ]; $bearerToken = FCM::getBearerToken($authKeyContent); FCM::subscribeToTopic($bearerToken, 'my-topic-1', $tokens);
Unsubscribe from topic
<?php $authKeyContent = json_decode(file_get_contents(__DIR__ . '/appname-30xfgre76.json'), true); $tokens = [ '<token1:string>', '<token2:string>', '<token3:string>', ]; $bearerToken = FCM::getBearerToken($authKeyContent); FCM::unsubscribeFromTopic($bearerToken, 'my-topic-1', $tokens);
统计信息
- 总下载量: 4.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-07
