码迷,mamicode.com
首页 > Web开发 > 详细

PHP--极光推送

时间:2018-12-21 13:18:17      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:订单   default   成功   gis   als   code   def   find   roi   

  /*
     * @param
     * @param 系统通知type为1
     * @param 聊天消息 type为2
     * @param 提醒付款 接单者确认订单 接单者取消订单 接单 type 为3
     * @param 发单者确认完成  发单者支付订单 发单者取消订单 type 为4
     * @param 充值成功 提现成功 退款成功 type为5
     */
    public function ceshi_jpush(){
        $datas = input(‘post.‘);
        $app_key = config("app_key");
        $master_secret = config("master_secret");
        $perinfoData = Db::table(‘shfw_member‘)->where("id",$datas["uid"])->field("re_id,token,nickname")->find();
        $client = new \JPush\Client($app_key, $master_secret);
        $pusher = $client->push();
        if(!$perinfoData["re_id"]){
            return_msg("100","re_id为空");
        }
        try{
            $response = $client->push()
           ->setPlatform(array(‘ios‘, ‘android‘))
            ->addRegistrationId($perinfoData["re_id"])
            ->iosNotification($datas["content"],array(
                    ‘sound‘=>‘default‘,
                    ‘badge‘ => 2,
                    ‘content-available‘ => true,
                    ‘category‘ => ‘jiguang‘,
                    "content_type"=>"1",
                    ‘extras‘ => [‘user_id‘=>$datas["uid"],‘type‘=>2,"nickname"=>$perinfoData["nickname"]]
                )
            )
            ->androidNotification($datas["content"],array(
                    ‘title‘ => $datas["content"],
                    ‘builder_id‘ => 1,
                    ‘extras‘ => array(
                        "user_id"=>$datas["uid"],‘type‘=>2,"nickname"=>$perinfoData["nickname"]),
                )
            )
            ->options([

                ‘time_to_live‘ => 86400,
                ‘apns_production‘ => false,
                ‘big_push_duration‘ => 0
            ])
            ->send();
//        return 1;
            return_msg("200","推送成功!");
    }catch (APIRequestException $e) {
return 2;
} catch (APIConnectionException $e) {
    return 3;
}

    }

 

PHP--极光推送

标签:订单   default   成功   gis   als   code   def   find   roi   

原文地址:https://www.cnblogs.com/yuancr/p/10153837.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!