push发出去php,unipush 服务端PHP不能离线发送

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小米不兼容啊所以发送不了商家通道发送。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值