type_id = $type_id; $this->type = $type; $this->content = $content; $this->from = $from; $this->to = $to; $this->image = $image; } /** * Execute the job. * * @return void */ public function handle() { $this->sendAttachMsg($this->type_id, $this->type, $this->content, $this->from, $this->to, $this->image); } /** * 发送推送消息 * @param [type] $type_id 类型id * @param [type] $type 类型 * @param [type] $content 推送文字 * @param [type] $from 来自用户 * @param [type] $to 接收用户 * @param [type] $image 来自用户头像 * @return [type] 是否成功 */ public function sendAttachMsg($type_id, $type, $content, $from, $to, $image) { $body = "点击查看>>"; //发送评论自定义系统消息 $im_service = new IMService(); $attach = ["myattach"=>$content, $type.'_id'=>$type_id]; $payload = [ "apsField"=>[ "alert"=>[ "title"=>$content, "body"=> $body, ], "mutable-content"=>1 ], "hwField"=>[ "click_action"=>[ "type"=>1, "intent"=>"intent://com.huawei.codelabpush/deeplink?id=".$type_id."&customType=".$type."#Intent;scheme=pushscheme;launchFlags=0x4000000;end", ], "title"=>$content, "body"=>$body, ], "oppoField"=>[ "click_action_type"=>1, "click_action_activity"=>"com.oppo.codelabpush.intent.action.test", "action_parameters"=>[ "id"=>$type_id, "customType"=>"moment", ], ], "apnsText"=>$body, "pushTitle"=>$content, "customType"=>$type, "content"=>$body, "media_image"=>$image, "media_type"=>'image', "id"=>$type_id, "type"=>$type, 'passThrough'=>1, ]; $result = $im_service->sendAttachMsg($from,0,$to,json_encode($attach),$content,$payload); return true; } }