PHP--極光推送


  /*
     * @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;
}

    }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM