wtf10029/getui

个推v2SDK

1.0.9 2022-02-11 03:36 UTC

This package is auto-updated.

Last update: 2024-03-08 10:46:28 UTC


README

个推SDK

配置
$config = (new \Getui\Config())->
    setAppId('appid')->
    setAppKey('appkey')->
    setMasterSecret('secret');
缓存
$redis = new \Redis();
$redis->connect('127.0.0.1',6379,0);
Authorization
$authorization = (new \Getui\Authorization($config))->withCacheDriver($redis);
绑定别名
(new \Getui\User())->withConfig($config)->withAuth($authorization)->aliasBind([
    [
        'cid'=>'ad9555f3c980cb0fe20de584ab9f0e3a',
        'alias'=>'15093570968'
    ]
]);
通过ClientId 获取别名
$alias = (new \Getui\User())->
withConfig($config)->
withAuth($authorization)->
getAliasByClientId('ad9555f3c980cb0fe20de584ab9f0e3a');
var_dump($alias);
指定Client Id 推送
(new \Getui\Push())->withConfig($config)->withAuth($authorization)->toSingleCid([
    'ad9555f3c980cb0fe20de584ab9f0e3a'
],(new \Getui\Message\NotificationMessage())->
setTitle('标题')->
setBody('内容')->
setClickType('payload')->
setPayload([
    'jump_type'=>1,
    'jump_value'=>2
]));
指定 别名 推送
(new \Getui\Push())->withConfig($config)->withAuth($authorization)->toSingleAlias([
    '15093570968'
],(new \Getui\Message\NotificationMessage())->
setTitle('标题')->
setBody('内容')->
setClickType('payload')->
setPayload([
    'jump_type'=>1,
    'jump_value'=>2
]));
推送全部用户
(new \Getui\Push())->withConfig($config)->withAuth($authorization)->toAll((new \Getui\Message\NotificationMessage())->
setTitle('标题')->
setBody('内容')->
setClickType('payload')->
setPayload([
    'jump_type'=>2,
    'jump_value'=>"id=1"
]));