作者 景龙
1 个管道 的构建 通过 耗费 1 秒

修改极光推送

... ... @@ -2198,17 +2198,16 @@ class CommonController extends RestBaseController
* $title:标题
* $extras:推送附加参数array()
*/
public function pushMessage($alias,$content,$title,$extras){
public function pushMessage($registration_id,$content,$title){
$app_key = config('site.app_key');
$master_secret = config('site.master_secret');
$client = new JPush($app_key, $master_secret);
$result = $client->push()
->setPlatform('all')
->addAllAudience()
->addAlias($alias)
->setMessage($content, $title,'text',$extras)
->addAndroidNotification($content,$title,1,$extras)
->addIosNotification($content, 'iOS sound', '+1', true, 'iOS category',$extras)
->addRegistrationId($registration_id)
->setMessage($content, $title,'text')
->addAndroidNotification($content,$title,1)
->addIosNotification($content, 'iOS sound', '+1', true, 'iOS category')
->send();
return $result;
}
... ...
... ... @@ -11,6 +11,7 @@ namespace api\home\controller;
use think\Db;
use think\Validate;
use cmf\controller\RestBaseController;
use app\portal\model\UserModel;
/**
* @title 首页
*/
... ... @@ -184,19 +185,24 @@ class IndexController extends RestBaseController
public function jpush(){
if($this->request->isGet()){
$registration_id = $this->request->get('registration_id');
$common = new CommonController();
$alias = [$registration_id];
$content = '您有一条消息,请注意查收';
$title = '推送消息';
$extras = '';
$res = $common->pushMessage($alias,$content,$title,$extras);
$this->success('成功',$res);
$userModel = new UserModel();
$userModel->where('id',$this->userId)->update(['registration_id'=>$registration_id]);
$this->success('成功');
}else{
$this->error('请求方式错误!');
}
}
//极光推送
public function pushRegistration(){
$registration_id = $this->request->get('registration_id');
$common = new CommonController();
$alias = [$registration_id];
$content = '您有一条消息,请注意查收';
$title = '推送消息';
$common->pushMessage($alias,$content,$title);
}
/**
* @title 员工项目列表
* @description 接口说明
... ...