// singleBatch
package getui
import (
"encoding/json"
"gugegin/tools"
"log"
"strings"
)
//【toSingle】执行cid批量单推
type Batch struct {
Is_async bool
Msg_list []Single
}
func Sba() {
cids := []string{"0373e181f3b1b36f1c725ea8e4f9492d"}
rd := tools.RandomStr(5)
noti := Notification{
Title: "Batch推标题" + rd,
Body: "Batch推内容" + rd,
Click_type: "none",
}
pus := Push_message{
Notification: noti,
}
aud := Audience{
Cid: cids,
}
signe := Single{
Request_id: tools.RandomStr(30),
Audience: aud,
Push_message: pus,
}
// sgs := []Single{}
// sgs = append(sgs, signe)
SingleBatch([]Single{signe})
}
//不同的内容推送给不同的用户,同时执行多次
func SingleBatch(mlist []Single) {
url := BASEURL + "/push/single/batch/cid"
log.Println(url)
batch := Batch{
Is_async: true,
Msg_list: mlist,
}
reqBody := strings.ToLower(tools.StructToJSON(batch))
s := tools.ClientPost2(url, strings.NewReader(reqBody), TokenValue)
sResult := PushResult{}
err := json.Unmarshal([]byte(s), &sResult)
if err != nil {
log.Println(err)
}
if sResult.Code == 0 {
log.Println("推送成功")
}
if sResult.Code == 10001 {
log.Println("--------SingleBatch----token过期或无效------")
//token过期
ObtainToken()
SingleBatch(mlist)
}
log.Println("--------SingleBatch-----msg-----", sResult.Msg)
}
个推批量单推
原创
©著作权归作者所有:来自51CTO博客作者wx62cbd84cdb743的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
ffmpeg推流flv到rtmp
c++音视频开发教程
音视频开发 c++音视频 rtmp 音视频编解码 -
个推
(3)别名推送:客户端绑定用户别名,向具体的单个用户推送;
推送 客户端 数据 -
推特中根据推文的id查找推文
在推特中,当我们浏览时,一条普通的推文的页面...
twitter 字段 后台服务器 用户名 -
服务器往android 设备 发送消息
一、Android手机客户端与服务器之间的通信----------阿冬专栏!!!方法一:通过json实现方法二: Socket接口进行通信。这样服务器端用servlet编写的程序可以与Socket接口进行通信在servlet中,也一样可以创建socket的 在servlet中,也一样可以创建 方法一的资源 Android客户端与服务器端的json数据交互(很详细) &nb
服务器往android 设备 发送消息 Android手机客户端 服务器 socket android