PHP--极光推送
Posted yuancr
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 JPushClient($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--极光推送的主要内容,如果未能解决你的问题,请参考以下文章