iansltx/gcm-client
Composer 安装命令:
composer require iansltx/gcm-client
包简介
A client for Firebase Cloud Messaging for Android's message API (via Legacy endpoints)
README 文档
README
gcm-client is a PHP library for interacting with Google Cloud Messaging for Android's HTTP API. It can be used to send messages to both Android Registration IDs and Notification Keys (for user-based multi-device messaging). It can also create and manipulate Notification Keys.
This library should conform to PSRs 1, 2, and 4, and requires PHP 7.2 or newer.
Install
Via Composer
$ composer require iansltx/gcm-client
If you don't want Composer, you may download the source zipball directly from GitHub and load it using a PSR-4 compliant
autoloader. If you don't have such an autoloader, require autoload.php to get one that works for this library.
Usage
<?php require "vendor/autoload.php"; $client = new iansltx\GCMClient\Client(YOUR_GCM_API_KEY); $message = new iansltx\GCMClient\Message(['title' => 'Notification', 'message' => 'Hello World!']); // send directly to one or more Registration IDs $regIdResult = $client->sendToRegIds($message, ['regId1', 'regId2']); $singleRegIdResult = $client->sendToRegIds($message, 'regId3'); // create a Notification Key for user-based messaging and send to that $nkClient = $client->withProjectId('myProjectId'); // a project ID is required for notification key manipulation $key = $nkClient->createNotificationKey('myUniqueKeyName', ['regId1', 'regId2']); $nkClient->addToNotificationKey($key, ['regId3'], 'myUniqueKeyName'); // returns the notification key $nkClient->removeFromNotificationKey($key, ['regId1'], 'myUniqueKeyName'); // returns the notification key $nKeyResult = $client->sendToNotificationKey($key, $message); // could use $nkClient to send as well
Take a look at the docblocks of Client and Message for more information.
Google changed the preferred location of the notification key field for their message-sending endpoint awhile back. This library has been updated to the new, non-deprecated, location. Additionally, it looks like they're requiring names when updating notification keys now; this used to be optional, hence its placement as the last parameter in the calls above.
As of v1.0, this library uses Google's non-deprecated FCM legacy endpoints (their words, not mind), rather than the old GCM endpoints that'll go offline on or after May 29th, 2019. So, despite the name, this library can be used with Firebase Cloud Messaging after May 2019.
Testing
$ composer test
PHPUnit is currently used for testing.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email iansltx@gmail.com instead of using the issue tracker.
Credits
License
This library is BSD 2-clause licensed. Please see License File for more information.
iansltx/gcm-client 适用场景与选型建议
iansltx/gcm-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 292 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 05 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「library」 「google」 「push」 「android」 「gcm」 「firebase」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 iansltx/gcm-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 iansltx/gcm-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 iansltx/gcm-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Apple Push Notification & Feedback Provider
Inbox pattern process implementation for your Laravel Applications
Laravel package to send push notifications to mobile devices (apns, gcm)
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
统计信息
- 总下载量: 292
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2015-05-26