sarehub/gcm
Composer 安装命令:
composer require sarehub/gcm
包简介
Google Cloud Messaging library for PHP
README 文档
README
A PHP library that allows you to send messages / push notifications to devices with your Android application installed.
Quick start
Required setup
The easiest way to install this library is via Composer.
Create a composer.json file and enter the following:
{
"require": {
"coreproc/gcm": "0.1.*"
}
}
If you haven't yet downloaded your composer file, you can do so by executing the following in your command line:
curl -sS https://getcomposer.org/installer | php
Once you've downloaded the composer.phar file, continue with your installation by running the following:
php composer.phar install
Usage
Basic Usage
The example below gives you a bare minimum of what to do to send a message / push notification.
<?php require 'vendor/autoload.php'; use Coreproc\Gcm\GcmClient; use Coreproc\Gcm\Classes\Message; $gcmClient = new GcmClient('your-gcm-api-key-here'); $message = new Message($gcmClient); $message->addRegistrationId('xxxxxxxxxx'); $message->setData([ 'title' => 'Sample Push Notification', 'message' => 'This is a test push notification using Google Cloud Messaging' ]); // More options are available in the Message class try { $response = $message->send(); // The send() method returns a Response object print_r($response); } catch (Exception $exception) { echo 'uh-oh: ' . $exception->getMessage(); }
How to obtain a GCM API key
- Log in to https://console.developers.google.com
- Create a new project and select the project after the project is created.
- Select the "APIs" option on the left menu sidebar.
- Look for "Google Cloud Messaging for Android" and turn it on.
- Next, go to "Credentials" option on the left menu sidebar.
- Click on the "Create new Key" button and make a new "Server Key".
- Enter the IP address of your server and hit "Create".
- Your API key should now appear on the page.
More Information
All options from the [https://developer.android.com/google/gcm/http.html](GCM HTTP Connection) are implemented in this library and they can be found in the Message class.
For more documentation on what options you can use, please refer to: https://developer.android.com/google/gcm/http.html.
sarehub/gcm 适用场景与选型建议
sarehub/gcm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 08 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 sarehub/gcm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sarehub/gcm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-08