octopusz / getui
基于laravel和lumen框架的个推push推送包
v1.0
2019-03-22 03:44 UTC
Requires
- laravel/framework: ~5.4
Requires (Dev)
- mockery/mockery: ^0.9.9
- phpunit/phpunit: ^6.3
This package is auto-updated.
Last update: 2024-09-22 17:06:42 UTC
README
基于 个推官方SDK for Laravel.
安装
$ composer require octopusz/getui -v
Laravel
// config/app.php 'providers' => [ //... Ocotpus\GeTui\GeTuiServiceProvider::class, //This is default in laravel 5.5 ],
并发布配置文件
$ php artisan vendor:publish --provider=Ocotpus\\GeTui\\GeTuiServiceProvider
如果您想使用外观模式,您可以注册一个您想使用的名称,例如 GeTui
// config/app.php 'aliases' => [ 'GeTui' => Ocotpus\GeTui\Facade\GeTui::class, //This is default in laravel 5.5 ],
Lumen
- 在 bootstrap/app.php 中 82 行左右:
$app->register(Ocotpus\GeTui\GeTuiServiceProvider::class);
将 vendor/ocotpusz/getui/src/config/getui.php 拷贝到项目根目录/config目录下,并将文件名改成getui.php。
配置
// config/getui.php // APP_EVN 你的项目当前环境:测试 or 生产 'app_env' => env('APP_ENV', 'development'), // The default default_client name which configured in `development` or `production` section //默认推送的客户端 'default_client' => 'client', 'development' => [ 'client' => [ 'appid' => 'your appid', //个推后后台获取相应app的参数 'appkey' => 'your appkey', 'appsecret' => 'your appsecret', 'mastersecret' => 'your mastersecret', 'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm', ], // other client ..... ], 'production' => [ 'client' => [ 'appid' => 'your appid', //个推后后台获取相应app的参数 'appkey' => 'your appkey', 'appsecret' => 'your appsecret', 'mastersecret' => 'your mastersecret', 'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm', ], // other client ..... ],
用法
网关实例
use GeTui; //针对单个或者多个用户推送 GeTui::push($deviceId, $data,true) //Using default default_client 推送给默认的客户端 GeTui::toClient('CLIENT NAME')->push($deviceId, $data) // CLIENT NAME is key name of `development` or `production` configuration. //自定义发送的客户端 // 针对整个app所有人推送 GeTui::pushToApp($data,true) ////Using default default_client GeTui::toClient('CLIENT NAME')->pushToApp($data) // GATEWAY NAME is key name of `development` or `production` configuration.
示例
$deviceId = '111111111111111'; // 多个push对象device_id 用数组传入 // $deviceId = [ // '111111111111111', // '222222222222222', // ]; $data = [ 'url' => '推送的url', 'title' => '这是个调皮的推送', 'content' => '想啥有啥', ]; $res = \GeTui::push($deviceId, $data,true); //Using default default_client print_r($res)
许可证
MIT