新人求助
个推怎么实现给部分指定用户推送消息
用户表有分群体的
我向给指定的用户群体发出推送 该如何实现?
本来自己有两种思路的
1 用自带的pushMessageToList接口实现
源码如下
function pushMessageToList()
{
putenv("gexin_pushList_needDetails=true");
putenv("gexin_pushList_needAsync=true");
$igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
//消息模版:
// 1.TransmissionTemplate:透传功能模板
// 2.LinkTemplate:通知打开链接功能模板
// 3.NotificationTemplate:通知透传功能模板
// 4.NotyPopLoadTemplate:通知弹框下载功能模板
//$template = IGtNotyPopLoadTemplateDemo();
//$template = IGtLinkTemplateDemo();
//$template = IGtNotificationTemplateDemo();
$template = IGtTransmissionTemplateDemo();
//个推信息体
$message = new IGtListMessage();
$message->set_isOffline(true);//是否离线
$message->set_offlineExpireTime(3600 * 12 * 1000);//离线时间
$message->set_data($template);//设置推送消息类型
// $message->set_PushNetWorkType(1); //设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
// $contentId = $igt->getContentId($message);
$contentId = $igt->getContentId($message,"2333"); //根据TaskId设置组名,支持下划线,中文,英文,数字
//接收方1
$target1 = new IGtTarget();
$target1->set_appId(APPID);
$target1->set_clientId(CID);
// $target1->set_alias(Alias);
$targetList[] = $target1;
$rep = $igt->pushMessageToList($contentId, $targetList);
var_dump($rep);
echo ("
");
}
但是发现这个接收方要列出来.也就是说要把每个用户的CID写出来.由于用户表里用户群体过大 所以放弃
二 用另一个群推的接口pushMessageToApp 源码如下
function pushMessageToApp(){
$igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
//$template = IGtLinkTemplateDemo(); //普通模板
$template = IGtNotificationTemplateDemo();//穿透消息
//个推信息体
//基于应用消息体
$message = new IGtAppMessage();
$message->set_isOffline(true);
$message->set_offlineExpireTime(10 * 60 * 1000);//离线时间单位为毫秒,例,两个小时离线为3600*1000*2
$message->set_data($template);
$appIdList=array(APPID);
//限制接收用户
$phoneTypeList=array('ANDROID');
$provinceList=array('四川');
$tagList=array('haha');
$age = array("0000", "0010");
$cdt = new AppConditions();
$cdt->addCondition(AppConditions::PHONE_TYPE, $phoneTypeList);
$cdt->addCondition(AppConditions::REGION, $provinceList);
$cdt->addCondition(AppConditions::TAG, $tagList);
$cdt->addCondition("age", $age);
$message->set_appIdList($appIdList);
// $message->condition = $cdt;
$rep = $igt->pushMessageToApp($message);
var_dump($rep);
echo ("
");
}
这个接口可以自定义标签,但没有找到相关的介绍
因此 求助各位前辈给点建议或者思路 如有相关文档更好