Commit 900ca3c1 authored by hujun's avatar hujun

推送修改

parent 53475b00
......@@ -31,31 +31,30 @@ class GeTuiUtils
/**
* 推送消息
*
* @param $device_id
* @param $push_id
* @param string $type
* @param $title
* @param $content
* @param null $id
* @param $data
* @return array
* @throws \Exception
*/
public function pushMessageToIgt($device_id, $type = 'other', $title, $content, $id = null)
public function pushMessageToIgt($push_id, $type = 'other', $title, $data)
{
$igt = new \IGeTui(self::IGT_HOST, self::IGT_APP_KEY, self::IGT_MASTER_SECRET);
$payload['title'] = $title;
$payload['content'] = $content;
$payload['type'] = $type;
$payload['url'] = "";
$payload['name'] = $title;
$payload['id'] = $id;
$payload['imageUrl'] = "";
$payload['title'] = $title;
$payload['type'] = $type; //0系统,1用户消息
$payload['msg_content'] = $data['msg_content'];
$payload['to_id'] = $data['to_id']; //接收人
$payload['from_id'] = $data['from_id']; //发送人
$payload['to_name'] = $data['to_name'];//接收人名字
$payload['from_name'] = $data['from_name'];//发送人名字
$payload['target_type'] = $data['target_type']; //1文字,2.图片 3.楼盘
$payload = json_encode($payload);
try {
//模板
$template = $this->onlineAllTemplate($payload, $title, $content);
$template = $this->onlineAllTemplate($payload, $title, $data['msg_content']);
} catch (\Exception $e) {
$result['code'] = 'failed';
$result['msg'] = '字数超过限制';
......@@ -72,16 +71,21 @@ class GeTuiUtils
//接收方
$target = new \IGtTarget();
$target->set_appId(self::IGT_APP_ID);
$target->set_clientId($device_id);
$res = $igt->pushMessageToSingle($message, $target);
$result = [];
if ($res['result'] == 'ok') {
$result['code'] = 'success';
$result['msg'] = $res['result'];
} else {
$result['code'] = 'failed';
$result['msg'] = $this->getReturnCode($res['result']);
foreach ($push_id as $k => $v) {
$target->set_clientId($v);
$res = $igt->pushMessageToSingle($message, $target);
if ($res['result'] == 'ok') {
$result['code'] = 'success';
$result['msg'] = $res['result'];
} else {
$result['code'] = 'failed';
$result['msg'] = $this->getReturnCode($res['result']);
break;
}
}
return $result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment