赞
踩
function pushToSingleByCid($title,$content,$payload,$cid,$package){
//创建API,APPID等配置参考 环境要求 进行获取
$api = new \GTClient("https://restapi.getui.com","XXX","XXX","XXX");
//设置推送参数
$push = new \GTPushRequest();
$osn = date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
$push->setRequestId((string)$osn);
$message = new \GTPushMessage();
$channel = new \GTPushChannel();
$notify = new \GTNotification();
$thirdnotify = new \GTThirdNotification();
$ups = new \GTUps();
$gtAndroid = new \GTAndroid();
$notify->setTitle($title);
$notify->setBody($content);
$thirdnotify->setTitle($title);
$thirdnotify->setBody($content);
if(is_array($payload))
$pj = json_encode($payload);
else
$pj = $payload;
$notify-> setPayload($pj);
$thirdnotify-> setPayload($pj);
$intent = "intent:#Intent;launchFlags=0x14000000;action=android.intent.action.oppopush;component={$package}/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title={$title};S.content={$content};S.payload={$pj};end";
$notify->setClickType("intent");
$thirdnotify->setClickType("intent");
$notify->setIntent($intent);
$thirdnotify->setIntent($intent);
echo $intent;
//点击通知后续动作,目前支持以下后续动作:
//1、intent:打开应用内特定页面url:打开网页地址。2、payload:自定义消息内容启动应用。3、payload_custom:自定义消息内容不启动应用。4、startapp:打开应用首页。5、none:纯通知,无后续动作
// $notify->setIntent($intent);
// $notify->setChannelLevel(3);
// $touchuan=['title'=>$title,'content'=>$content,'payload'=>$package];
//$message->setTransmission(json_encode($touchuan));
//$message->setNotification($notify);
$upsback= $ups->setNotification($thirdnotify);
// $upsback= $ups->setTransmission('透传');
$gtAndroid->setUps($ups);
$channel->setAndroid($gtAndroid);
//$push->setPushMessage($message);
$push->setPushChannel( $channel);
$push->setCid($cid);
//处理返回结果
$result = $api->pushApi()->pushToSingleByCid($push);
}
这个能在线推送,但是不能离线推送,dcloud后台推送单推却可以离线成功,但是服务端不能。以上是PHP代码了,V2 版SDK.而且都是参考SDK的demo的第三方厂商家通道发送,都是不能发送的,而且在小米推送后台输入CID弹出输入的regId格式不正确,请确认regid是否不全是数字且长度为44或64或128的错误,是不是CID小米不兼容啊所以发送不了商家通道发送。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。