bigbank/gcm-message
Composer 安装命令:
composer require bigbank/gcm-message
包简介
A PHP library to send messages to devices registered through Google Cloud Messaging
README 文档
README
A PHP library to send messages to devices registered through Google Cloud Messaging
See GCM documentation: http://developer.android.com/guide/google/gcm/index.html
Example usage
use Bigbank\Gcm\Sender; use Bigbank\Gcm\Message; $sender = new Sender("YOUR GOOGLE API KEY", $GcmEndpoint); $message = new Message( ["device_registration_id1", "device_registration_id2"], ["data1" => "123", "data2" => "string"] ); $message ->notification(["title" => "foo", "body" => "bar"]) ->setCollapseKey("collapse_key") ->setDelayWhileIdle(true) ->setTtl(123) ->setRestrictedPackageName("com.example") ->setDryRun(true) ; try { $response = $sender->send($message); } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); }
Note about cURL SSL verify peer option
Library has turned off CURLOPT_SSL_VERIFYPEER by default, but you can enable it by passing third parameter into constructor of Sender class.
You need to download root certificates and add them somewhere into your project directory. Then construct Sender object like this:
use Bigbank\Gcm\Sender; $sender = new Sender("YOUR GOOGLE API KEY", $GcmEndpoint, "/path/to/cacert.crt");
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Credits
- [Bigbank's developers][link-bb-developers]
- [All Contributors][link-contributors]
License
The Apache 2 License. Please see License File for more information.
统计信息
- 总下载量: 103
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2016-06-28