1。检查参数是否正确。2、不能先使用透传方式。3、是否设置了厂商频道的消息内容。4.intent参数设置为在应用程序中打开特定页面。5、intent参数是否正确?意图:#Intent;component=packagename/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title=".urlencode(title).";S.content=".urlencode($content).";S.payload=".json_encode(你的自定义参数).";end6.PHP参考代码。$api=newGTClient("https://restapi.getui.com/","","","");$stt=['默认'=>1];//设置推送参数$push=newGTPushRequest();$push->setRequestId(time());$message=newGTPushMessage();$notify=newGTNotification();$channel=newGTPushChannel();//配置推送条件$str=newGTStrategy();$str->setDefault(1);$str->setHw(1);$setting=newGTSettings();//没有定时推送$setting->setStrategy($str);$push->setSettings($setting);$setting->setTtl(3600000);////消息有效期,厂商消息需要设置该值//推送苹果离线通知标题内容$alert=newGTAlert();$alert->setTitle($title);$alert->setBody($content);$aps=新GTAps();//1表示静默推送(无通知栏消息),静默推送不需要填写其他参数。//Apple建议每小时最多推送3条静默消息$aps->setContentAvailable(0);$aps->setSound("默认");$aps->setAlert($alert);$iosDto=newGTIos();$iosDto->setAps($aps);$iosDto->setType("通知");$pushChannel=newGTPushChannel();$pushChannel->setIos($iosDto);//Android线下厂商渠道推送消息体$pushChannel=newGTPushChannel();$androidDTO=newGTAndroid();$ups=新的GTUps();$notification1=newGTTTirdNotification();;$notification1->setTitle($title);$notification1->setBody($content);$ups->setNotification($notification1);if($clickType=='none')//设置推送类型{$notification1->setClickType($clickType);}elseif($clickType=='payload'||$clickType=='payload_custom'){//自定义消息打开APP和不打开APP$notification1->setClickType($clickType);$notification1->setPayload(json_encode($数据));}elseif($clickType=='url'){//打开URL$notification1->setClickType($clickType);$notification1->setUrl($url);}elseif($clickType=='intent'){//打开特定页面$notification1->setClickType($clickType);$notification1->setIntent("intent:#Intent;component=packagename/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title=".urlencode($title).";S.content=".urlencode($content).";S.payload=".json_encode($data).";end");}else{$notification1->setClickType($clickType);}//各厂商自己的功能单项设置if($time){$message->setDuration($time);//设置推送时间$data=json_encode(array('title'=>$title,'content'=>$content,'duration'=>$time,'importance'=>'HIGH','payload'=>json_encode($数据)));}else{$data=json_encode(array('title'=>$title,'content'=>$content,'payload'=>json_encode($data)));}//$ups->setTransmission($data);$androidDTO->setUps($ups);$pushChannel->setAndroid($androidDTO);$push->setPushChannel($pushChannel);//一个推送在线Channel$notify->setTitle($title);$notify->setBody($content);如果($img)$notify->setBigImage($img);//推送图片//1、intent:打开应用专用页面2、url:打开网页地址3、payload:自定义启动应用的消息内容。4.payload_custom:自定义消息内容不启动应用。5.startapp:打开应用程序的首页。6.none:纯通知,无后续动作if($clickType=='none')//设置推送类型{$notify->setClickType($clickType);}elseif($clickType=='payload'||$clickType=='payload_custom'){//自定义消息打开APP或不打开APP$notify->setClickType($clickType);$notify->setPayload(json_encode($data));}elseif($clickType=='url'){//打开URL$notify->setClickType($clickType);$notify->setUrl($url);}elseif($clickType=='intent'){//打开特定页面$notify->setClickType($clickType);$notify->setIntent("intent:#Intent;component=packagename/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title=".urlencode($title).";S.content=".urlencode($content).";S.payload=".json_encode($data).";end");}else{$notify->setClickType($clickType);}$message->setNotification($notify);$push->setPushMessage($message);/*如果($时间){$message->setDuration($time);//设置推送时间$data=json_encode(array('title'=>$title,'body'=>$content,'duration'=>$time,'importance'=>'HIGH','payload'=>json_encode($数据)));}else{$data=json_encode(array('title'=>$title,'body'=>$content,'payload'=>json_encode($data)));}$ups->setTransmission($data);//$android->setUps($ups);$channel->setAndroid($android);$push->setPushChannel($channel);$push->setPushMessage($message);*/if($cid)//推送给用户{$push->setCid($cid);//处理返回结果$result=$api->pushApi()->pushToSingleByCid($push);}else{$result=$api->pushApi()->pushAll($push);}Log::info('推送数据:【推送】'.json_encode($result));//写入日志return$result;
