endroid / gcm
此包已废弃,不再维护。未建议替代包。
Endroid Google Cloud Messaging
1.3.1
2017-01-01 15:06 UTC
Requires
- php: >=5.4
- ext-curl: *
- kriswallsmith/buzz: ~0.3
Requires (Dev)
- phpunit/phpunit: ^4.0|^5.0
README
作者 endroid
Google Cloud Messaging 是一种帮助开发者将数据从服务器发送到其 Android 设备上的 Android 应用程序的服务。有关更多信息,请参阅 Google GCM。
针对 1000+ 注册 ID 的消息请求将自动分块并行发送,以规避 Google 强制设定的最大限制。因此,在使用此类时无需担心此限制。
use Endroid\Gcm\Client; $apiKey = '...'; $client = new Client($apiKey); // Registration ID's of devices to target $registrationIds = [ //... ]; $data = [ 'title' => 'Message title', 'message' => 'Message body', ]; $success = $client->send($data, $registrationIds);
如果出现问题或您只想检查 GCM 服务器返回的响应对象,可以使用 getResponses() 方法检索这些对象。
Symfony 集成
在内核中注册 Symfony 扩展包。
// app/AppKernel.php public function registerBundles() { $bundles = [ // ... new Endroid\Gcm\Bundle\EndroidGcmBundle(), ]; }
默认参数可以通过配置覆盖。
endroid_gcm: api_key: '...'
现在您可以按如下方式检索客户端。
$client = $this->get('endroid.gcm.client');
版本控制
版本号遵循 MAJOR.MINOR.PATCH 体系结构。向后兼容性破坏性更改将保持在最低限度,但请注意,这些更改可能发生。在生产中锁定依赖项,并在升级时测试您的代码。
许可
此包受 MIT 许可证的约束。有关完整的版权和许可信息,请参阅与此源代码一起分发的 LICENSE 文件。