Getui.php 25.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572
<?php

namespace app\common\library;
require_once(dirname(__FILE__) . '/' . '../../../extend/getui-pushapi-v2/GTClient.php');
/**
 * 个推相关功能调用
 * Class Getui
 * @package app\common\library
 */
class Getui
{
    public $appId;
    public $appKey;
    public $appSecret;
    public $masterSecret;
    public $api;
    public $domainUrl = 'https://restapi.getui.com';
    public function __construct()
    {
        $config = config('getui');
        $this->appId = $config['appId'];
        $this->appKey = $config['appKey'];
        $this->appSecret = $config['appSecret'];
        $this->masterSecret = $config['masterSecret'];
        $this->api = new \GTClient($this->domainUrl, $this->appKey, $this->appId, $this->masterSecret);
    }

    /**
     * 基础参数和消息设置
     * @param $notifyTitle      //通知标题 取所有设备最小集:最多允许20个汉字
     * @param $notifyBody       //通知内容 取所有设备最小集:最多允许50个汉字
     * @param string $clickType //点击类型默认是none://intent:打开应用内特定页面url:打开网页地址。payload:自定义消息内容启动应用 payload_custom:自定义消息内容不启动应用。startapp:打开应用首页。none:纯通知,无后续动作
     * @param string $url       //非必传,clickType=url时必传
     * @param string $payload   //非必传,clickType=payload或者payload_custom时必传
     * @param string $intent    //非必传,clickType=intent时必传
     * @return \GTPushRequest
     */
    public function setParam($notifyTitle, $notifyBody, $clickType = 'none', $url = '', $payload = '', $intent = ''){
        if (mb_strlen($notifyTitle) > 20){
            $notifyTitle = mb_substr($notifyTitle, 0, 20);
        }
        if (mb_strlen($notifyBody) > 50){
            $notifyBody = mb_substr($notifyBody, 0, 50);
        }

        //基础设置
        $set = new \GTSettings();
        //消息离线时间设置,单位毫秒,-1表示不设离线,-1 ~ 3 * 24 * 3600 * 1000(3天)之间,默认值是2小时
        $set->setTtl(3600000);//1天
        //$set->setSpeed(1000);//定速推送,例如100,个推控制下发速度在100条/秒左右,0表示不限速
        //$set->setScheduleTime(1591794372930);//定时推送时间,必须是7天内的时间,格式:毫秒时间戳,此功能需要开通VIP

        //厂商通道设置,需要vip才能用
        $strategy = new \GTStrategy();
        $strategy->setDefault(\GTStrategy::STRATEGY_GT_FIRST);
        //$strategy->setIos(GTStrategy::STRATEGY_GT_ONLY);
        //$strategy->setOp(GTStrategy::STRATEGY_THIRD_FIRST);
        //$strategy->setHw(GTStrategy::STRATEGY_THIRD_ONLY);
        $set->setStrategy($strategy);

        //设置通知
        $notify = new \GTNotification();
        $notify->setTitle($notifyTitle);
        $notify->setBody($notifyBody);
        //点击通知后续动作,目前支持以下后续动作:
        //1、intent:打开应用内特定页面url:打开网页地址。2、payload:自定义消息内容启动应用。3、payload_custom:自定义消息内容不启动应用。4、startapp:打开应用首页。5、none:纯通知,无后续动作
        $notify->setClickType($clickType);
        switch ($clickType) {
            case 'none':    //纯通知,无后续动作
                break;
            case 'startapp'://打开应用首页
                break;
            case 'url'://打开网页地址
                $notify->setUrl($url);
                break;
            case 'payload_custom'://自定义消息内容不启动应用
                $notify->setPayload($payload);
                break;
            case 'payload'://自定义消息内容启动应用
                $notify->setPayload($payload);
                break;
            case 'intent'://打开应用内特定页面
                $notify->setIntent($intent);
                break;
            default:
        }

        //设置消息
        $message = new \GTPushMessage();
        $message->setNotification($notify);

        //设置推送
        $push = new \GTPushRequest();
        $push->setRequestId($this->micro_time());
        $push->setSettings($set);
        $push->setPushMessage($message);
        return $push;
    }

    /**
     * 执行cid单推
     * @param $cid              //唯一标识CID
     * @param $notifyTitle      //通知标题
     * @param $notifyBody       //通知内容
     * @param string $clickType //点击类型默认是none://intent:打开应用内特定页面url:打开网页地址。payload:自定义消息内容启动应用 payload_custom:自定义消息内容不启动应用。startapp:打开应用首页。none:纯通知,无后续动作
     * @param string $url       //非必传,clickType=url时必传
     * @param string $payload   //非必传,clickType=payload或者payload_custom时必传
     * @param string $intent    //非必传,clickType=intent时必传
     * @return mixed|null|array
     * {
            "msg": "success",
            "code": 0,      //成功
            "data": {
     *          //任务taskId
                "RASS_1017_2be55039a526980847ec44df6138419a": {
     *              //唯一标识cid                        //推送结果successed_offline: 离线下发(包含厂商通道下发),successed_online: 在线下发,successed_ignore: 最近90天内不活跃用户不下发
                    "d273516dcc0e25e02d47f1412b5b4dc2": "successed_online"
                    }
                }
        }
     */
    public function pushToSingleByCid($cid, $notifyTitle, $notifyBody, $clickType = 'none', $url = '', $payload = '', $intent = ''){
        $push = $this->setParam($notifyTitle, $notifyBody, $clickType, $url, $payload, $intent);
        $push->setCid($cid);

        //发起推送
        $response = $this->api->pushApi()->pushToSingleByCid($push);
        return $response;
    }

    /**
     * 执行别名单推
     * @param $alias            //别名
     * @param $notifyTitle      //通知标题
     * @param $notifyBody       //通知内容
     * @param string $clickType //点击类型默认是none://intent:打开应用内特定页面url:打开网页地址。payload:自定义消息内容启动应用 payload_custom:自定义消息内容不启动应用。startapp:打开应用首页。none:纯通知,无后续动作
     * @param string $url       //非必传,clickType=url时必传
     * @param string $payload   //非必传,clickType=payload或者payload_custom时必传
     * @param string $intent    //非必传,clickType=intent时必传
     * @return mixed|null|array
     * {
        "msg": "success",
        "code": 0,      //成功
        "data": {
     *          //任务taskId
                "RASS_1017_2be55039a526980847ec44df6138419a": {
     *              //唯一标识cid                        //推送结果successed_offline: 离线下发(包含厂商通道下发),successed_online: 在线下发,successed_ignore: 最近90天内不活跃用户不下发
                    "d273516dcc0e25e02d47f1412b5b4dc2": "successed_online"
                    }
                }
        }
     */
    public function pushToSingleByAlias($alias, $notifyTitle, $notifyBody, $clickType = 'none', $url = '', $payload = '', $intent = ''){
        $push = $this->setParam($notifyTitle, $notifyBody, $clickType, $url, $payload, $intent);
        $push->setAlias($alias);

        $response = $this->api->pushApi()->pushToSingleByAlias($push);
        return $response;
    }

    /**
     * 执行cid批量单推
     * @param $cid      //唯一标识CID
     * @param array $data     //消息体
     * $data = [
     *     [
     *          'notifyTitle' = '通知标题',//必传
     *          'notifyBody'  = '通知内容',//必传
     *          'clickType'   = 'none', //intent:打开应用内特定页面url:打开网页地址。payload:自定义消息内容启动应用 payload_custom:自定义消息内容不启动应用。startapp:打开应用首页。none:纯通知,无后续动作
     *          'url'         = '',//非必传,clickType=url时必传
     *          'payload'     = '',//非必传,clickType=payload或者payload_custom时必传
     *          'intent'      = '',//非必传,clickType=intent时必传
     *      ],
     *      ...
     * ]
     * @return array|bool
     * {
        "msg": "success",
        "code": 0,      //成功
        "data": {
     *          //任务taskId
                "RASS_1017_2be55039a526980847ec44df6138419a": {
     *              //唯一标识cid                        //推送结果successed_offline: 离线下发(包含厂商通道下发),successed_online: 在线下发,successed_ignore: 最近90天内不活跃用户不下发
                    "d273516dcc0e25e02d47f1412b5b4dc2": "successed_online"
                    }
                },
     *          ...
        }
     */
    public function pushBatchByCid($cid, array $data){
        if (!is_array($data)){
            return false;
        }
        $batch = new \GTPushBatchRequest();
        $pushArr = [];//数组长度不大于200
        foreach ($data as $param){
            $push = $this->setParam($param['notifyTitle'], $param['notifyBody'], $param['clickType'], $param['url'] ?? '', $param['payload'] ?? '', $param['intent'] ?? '');
            $push->setCid($cid);
            $pushArr[] = $push;
        }
        $batch->setIsAsync(false);//是否异步推送,true是异步,false同步。异步推送不会返回data详情
        $batch->setMsgList($pushArr);
        //$batch->addMsgList($push1);//单独增加推送消息使用

        $response = $this->api->pushApi()->pushBatchByCid($batch);
        return $response;
    }

    /**
     * 执行别名批量单推
     * @param $alias      //别名
     * @param array $data     //消息体
     * $data = [
     *     [
     *          'notifyTitle' = '通知标题',//必传
     *          'notifyBody'  = '通知内容',//必传
     *          'clickType'   = 'none', //intent:打开应用内特定页面url:打开网页地址。payload:自定义消息内容启动应用 payload_custom:自定义消息内容不启动应用。startapp:打开应用首页。none:纯通知,无后续动作
     *          'url'         = '',//非必传,clickType=url时必传
     *          'payload'     = '',//非必传,clickType=payload或者payload_custom时必传
     *          'intent'      = '',//非必传,clickType=intent时必传
     *      ],
     *      ...
     * ]
     * @return array|bool
     * {
            "msg": "success",
            "code": 0,      //成功
            "data": {
     *          //任务taskId
                "RASS_1017_2be55039a526980847ec44df6138419a": {
     *              //唯一标识cid                        //推送结果successed_offline: 离线下发(包含厂商通道下发),successed_online: 在线下发,successed_ignore: 最近90天内不活跃用户不下发
                    "d273516dcc0e25e02d47f1412b5b4dc2": "successed_online"
                    }
                },
     *          ...
        }
     */
    public function pushBatchByAlias($alias, array $data){
        if (!is_array($data)){
            return false;
        }
        $batch = new \GTPushBatchRequest();
        $pushArr = [];//数组长度不大于200
        foreach ($data as $param){
            $push = $this->setParam($param['notifyTitle'], $param['notifyBody'], $param['clickType'], $param['url'] ?? '', $param['payload'] ?? '', $param['intent'] ?? '');
            $push->setAlias($alias);
            $pushArr[] = $push;
        }
        $batch->setIsAsync(false);//是否异步推送,true是异步,false同步。异步推送不会返回data详情
        $batch->setMsgList($pushArr);
        //$batch->addMsgList($push1);//单独增加推送消息使用

        $response = $this->api->pushApi()->pushBatchByAlias($batch);
        return $response;
    }

    /**
     * 此接口用来创建消息体,并返回taskid,为批量推的前置步骤
     * @param $groupName        //任务组名
     * @param $notifyTitle      //通知标题
     * @param $notifyBody       //通知内容
     * @param string $clickType //点击类型默认是none://intent:打开应用内特定页面url:打开网页地址。payload:自定义消息内容启动应用 payload_custom:自定义消息内容不启动应用。startapp:打开应用首页。none:纯通知,无后续动作
     * @param string $url       //非必传,clickType=url时必传
     * @param string $payload   //非必传,clickType=payload或者payload_custom时必传
     * @param string $intent    //非必传,clickType=intent时必传
     * @return mixed|null|array
     */
    public function createListMsg($groupName, $notifyTitle, $notifyBody, $clickType = 'none', $url = '', $payload = '', $intent = ''){
        $push = $this->setParam($notifyTitle, $notifyBody, $clickType, $url, $payload, $intent);
        $push->setGroupName($groupName);

        $response = $this->api->pushApi()->createListMsg($push);
        return $response;
    }

    /**
     * 执行cid批量推
     * @param $taskId       //批量推消息体taskId,从createListMsg接口获取得来
     * @param array $cidArr //cid数组
     * @return mixed|null|array
     * {
            "msg": "success",
            "code": 0,      //成功
            "data": {
     *          //任务taskId
                "RASS_1017_2be55039a526980847ec44df6138419a": {
     *              //唯一标识cid                        //推送结果successed_offline: 离线下发(包含厂商通道下发),successed_online: 在线下发,successed_ignore: 最近90天内不活跃用户不下发
                    "d273516dcc0e25e02d47f1412b5b4dc2": "successed_online",
     *              "d273516dcc0e25e02d47f1412b5b4dc3": "successed_online"
                    }
                }
        }
     */
    public function pushListByCid($taskId, array $cidArr){
        $user = new \GTAudienceRequest();
        $user->setIsAsync(false);
        $user->setTaskid($taskId);
        $user->setCidList($cidArr);
        $response = $this->api->pushApi()->pushListByCid($user);
        return $response;
    }

    /**
     * 执行别名批量推
     * @param $taskId       //批量推消息体taskId,从createListMsg接口获取得来
     * @param array $aliasArr //alias数组
     * @return mixed|null|array
     * {
            "msg": "success",
            "code": 0,      //成功
            "data": {
     *          //任务taskId
                "RASS_1017_2be55039a526980847ec44df6138419a": {
     *              //唯一标识cid                        //推送结果successed_offline: 离线下发(包含厂商通道下发),successed_online: 在线下发,successed_ignore: 最近90天内不活跃用户不下发
                    "d273516dcc0e25e02d47f1412b5b4dc2": "successed_online",
     *              "d273516dcc0e25e02d47f1412b5b4dc3": "successed_online"
                    }
                }
        }
     */
    public function pushListByAlias($taskId, $aliasArr){
        $user = new \GTAudienceRequest();
        $user->setIsAsync(false);
        $user->setTaskid($taskId);
        $user->setAliasList($aliasArr);
        $response = $this->api->pushApi()->pushListByAlias($user);
        return $response;
    }

    /**
     * 执行群推
     * @param $groupName        //任务组名
     * @param $notifyTitle      //通知标题
     * @param $notifyBody       //通知内容
     * @param string $clickType //点击类型默认是none://intent:打开应用内特定页面url:打开网页地址。payload:自定义消息内容启动应用 payload_custom:自定义消息内容不启动应用。startapp:打开应用首页。none:纯通知,无后续动作
     * @param string $url       //非必传,clickType=url时必传
     * @param string $payload   //非必传,clickType=payload或者payload_custom时必传
     * @param string $intent    //非必传,clickType=intent时必传
     * @return mixed|null|array
     * {
            "msg": "success",
            "code": 0,
            "data": {
                "taskid": "RASA_1017_baaaf387f6a9b0e4099f73f86cfd6f66"
            }
        }
     */
    public function pushAll($groupName, $notifyTitle, $notifyBody, $clickType = 'none', $url = '', $payload = '', $intent = ''){
        $push = $this->setParam($notifyTitle, $notifyBody, $clickType, $url, $payload, $intent);
        $push->setGroupName($groupName);
        $response = $this->api->pushApi()->pushAll($push);
        return $response;
    }

    /**
     * 创建tag推送条件
     * @param $opt_type         //or(或),and(与),not(非),values间的交并补操作
     * @param $key              //查询条件(phone_type 手机类型; region 省市; custom_tag 用户标签; portrait 个推用户画像)
     * @param array $values     //查询条件值列表,其中key='phone_type'时使用如下参数['android','ios','miniProgram'],也可以只选一个或两个
     *                          //key='region' 时使用如下参数['11000000','12000000'],11000000代表北京市,12000000代表天津市,省市编码查看文件application/common/library/getui/region_code.data
     *                          //key='portrait' 时查看文件application/common/library/getui/portrait.data
     * @return \GTCondition
     */
    public function createTag($opt_type, $key, array $values){
        $tag = new \GTCondition();
        $tag->setOptType($opt_type);
        $tag->setKey($key);
        $tag->setValues($values);
        return $tag;
    }

    /**
     * 根据条件筛选用户推送,对指定应用的符合筛选条件的用户群发推送消息
     * @param array $tagArr //通过createTag方法获取tag对象,自己组装成数组即可
     * @param $notifyTitle      //通知标题
     * @param $notifyBody       //通知内容
     * @param string $clickType //点击类型默认是none://intent:打开应用内特定页面url:打开网页地址。payload:自定义消息内容启动应用 payload_custom:自定义消息内容不启动应用。startapp:打开应用首页。none:纯通知,无后续动作
     * @param string $url       //非必传,clickType=url时必传
     * @param string $payload   //非必传,clickType=payload或者payload_custom时必传
     * @param string $intent    //非必传,clickType=intent时必传
     * @return mixed|null|array
     * {
            "msg": "success",
            "code": 0,
            "data": {
                "taskid": "RASA_1017_95921b0020e8ee6b9db47be86f49f1bb"
                }
        }
     */
    public function pushByTag(array $tagArr, $notifyTitle, $notifyBody, $clickType = 'none', $url = '', $payload = '', $intent = ''){
        $push = $this->setParam($notifyTitle, $notifyBody, $clickType, $url, $payload, $intent);

        $push->setTagList($tagArr);
        $response = $this->api->pushApi()->pushByTag($push);
        return $response;
    }

    /**
     * 使用标签快速推送,根据标签过滤用户并推送
     * @param $tagName          //自定义标签名
     * @param $notifyTitle      //通知标题
     * @param $notifyBody       //通知内容
     * @param string $clickType //点击类型默认是none://intent:打开应用内特定页面url:打开网页地址。payload:自定义消息内容启动应用 payload_custom:自定义消息内容不启动应用。startapp:打开应用首页。none:纯通知,无后续动作
     * @param string $url       //非必传,clickType=url时必传
     * @param string $payload   //非必传,clickType=payload或者payload_custom时必传
     * @param string $intent    //非必传,clickType=intent时必传
     * @return mixed|null|array
     */
    public function pushByFastCustomTag($tagName, $notifyTitle, $notifyBody, $clickType = 'none', $url = '', $payload = '', $intent = ''){
        $push = $this->setParam($notifyTitle, $notifyBody, $clickType, $url, $payload, $intent);

        $push->setFastCustomTag($tagName);
        $response = $this->api->pushApi()->pushByFastCustomTag($push);
        return $response;
    }

    /**
     * 停止任务,对正处于推送状态,或者未接收的消息停止下发(只支持批量推和群推任务)
     * @param $taskId           //任务ID
     * @return mixed|null|array
     */
    public function stopPushApi($taskId){
        $response = $this->api->pushApi()->stopPush($taskId);
        return $response;
    }

    /**
     * 查询定时任务,该接口支持在推送完定时任务之后,查看定时任务状态,定时任务是否发送成功。vip功能
     * @param $taskId           //任务ID
     * @return mixed|null|array
     */
    public function queryScheduleTask($taskId){
        $response = $this->api->pushApi()->queryScheduleTask($taskId);
        return $response;
    }

    /**
     * 删除定时任务,用来删除还未下发的任务,删除后定时任务不再触发(距离下发还有一分钟的任务,将无法删除,后续可以调用停止任务接口。)
     * @param $taskId           //任务ID
     * @return mixed|null|array
     */
    public function deleteScheduleTask($taskId){
        $response = $this->api->pushApi()->deleteScheduleTask($taskId);
        return $response;
    }

    /**
     * 获取毫秒
     * @return string
     */
    public function micro_time()
    {
        list($usec, $sec) = explode(" ", microtime());
        $time = ($sec . substr($usec, 2, 3));
        return $time;
    }

    //设置参数案例(参考使用)
    private function getParam(){
        $push = new \GTPushRequest();
        $push->setRequestId($this->micro_time());
        //设置setting
        $set = new \GTSettings();
        $set->setTtl(3600000);
//    $set->setSpeed(1000);
//    $set->setScheduleTime(1591794372930);
        $strategy = new \GTStrategy();
        $strategy->setDefault(\GTStrategy::STRATEGY_THIRD_FIRST);
//    $strategy->setIos(GTStrategy::STRATEGY_GT_ONLY);
//    $strategy->setOp(GTStrategy::STRATEGY_THIRD_FIRST);
//    $strategy->setHw(GTStrategy::STRATEGY_THIRD_ONLY);
        $set->setStrategy($strategy);
        $push->setSettings($set);
        //设置PushMessage,
        $message = new \GTPushMessage();
        //通知
        $notify = new \GTNotification();
        $notify->setTitle("notdifyddd");
        $notify->setBody("notify bdoddy");
        $notify->setBigText("bigTdext");
        //与big_text二选一
//    $notify->setBigImage("BigImage");

        $notify->setLogo("push.png");
        $notify->setLogoUrl("LogoUrl");
        $notify->setChannelId("Default");
        $notify->setChannelName("Default");
        $notify->setChannelLevel(2);

        $notify->setClickType("none");
        $notify->setIntent("intent:#Intent;component=你的包名/你要打开的 activity 全路径;S.parm1=value1;S.parm2=value2;end");
        $notify->setUrl("url");
        $notify->setPayload("Payload");
        $notify->setNotifyId(22334455);
        $notify->setRingName("ring_name");
        $notify->setBadgeAddNum(1);
//    $message->setNotification($notify);
        //透传 ,与通知、撤回三选一
        $message->setTransmission("试试透传");
        //撤回
        $revoke = new \GTRevoke();
        $revoke->setForce(true);
        $revoke->setOldTaskId("taskId");
//    $message->setRevoke($revoke);
        $push->setPushMessage($message);
        $message->setDuration("1590547347000-1590633747000");
        //厂商推送消息参数
        $pushChannel = new \GTPushChannel();
        //ios
        $ios = new \GTIos();
        $ios->setType("notify");
        $ios->setAutoBadge("1");
        $ios->setPayload("ios_payload");
        $ios->setApnsCollapseId("apnsCollapseId");
        //aps设置
        $aps = new \GTAps();
        $aps->setContentAvailable(0);
        $aps->setSound("com.gexin.ios.silenc");
        $aps->setCategory("category");
        $aps->setThreadId("threadId");

        $alert = new \GTAlert();
        $alert->setTitle("alert title");
        $alert->setBody("alert body");
        $alert->setActionLocKey("ActionLocKey");
        $alert->setLocKey("LocKey");
        $alert->setLocArgs(array("LocArgs1","LocArgs2"));
        $alert->setLaunchImage("LaunchImage");
        $alert->setTitleLocKey("TitleLocKey");
        $alert->setTitleLocArgs(array("TitleLocArgs1","TitleLocArgs2"));
        $alert->setSubtitle("Subtitle");
        $alert->setSubtitleLocKey("SubtitleLocKey");
        $alert->setSubtitleLocArgs(array("subtitleLocArgs1","subtitleLocArgs2"));
        $aps->setAlert($alert);
        $ios->setAps($aps);

        $multimedia = new \GTMultimedia();
        $multimedia->setUrl("url");
        $multimedia->setType(1);
        $multimedia->setOnlyWifi(false);
        $multimedia2 = new \GTMultimedia();
        $multimedia2->setUrl("url2");
        $multimedia2->setType(2);
        $multimedia2->setOnlyWifi(true);
        $ios->setMultimedia(array($multimedia));
        $ios->addMultimedia($multimedia2);
        $pushChannel->setIos($ios);
        //安卓
        $android = new \GTAndroid();
        $ups = new \GTUps();
//    $ups->setTransmission("ups Transmission");
        $thirdNotification = new \GTThirdNotification();
        $thirdNotification->setTitle("title".$this->micro_time());
        $thirdNotification->setBody("body".$this->micro_time());
        $thirdNotification->setClickType(\GTThirdNotification::CLICK_TYPE_URL);
        $thirdNotification->setIntent("intent:#Intent;component=你的包名/你要打开的 activity 全路径;S.parm1=value1;S.parm2=value2;end");
        $thirdNotification->setUrl("http://docs.getui.com/getui/server/rest_v2/push/");
        $thirdNotification->setPayload("payload");
        $thirdNotification->setNotifyId(456666);
        $ups->addOption("HW","badgeAddNum",1);
        $ups->addOption("OP","channel","Default");
        $ups->addOption("OP","aaa","bbb");
        $ups->addOption(null,"a","b");

        $ups->setNotification($thirdNotification);
        $android->setUps($ups);
        $pushChannel->setAndroid($android);
        $push->setPushChannel($pushChannel);

        return $push;
    }
}