-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Android可以正常收发,IOS,retcode是0,但是客户端收不到,麻烦帮忙看下,多谢
`func PushIOSMessage(rids []int, title, content, appID, secretKey string) error {
accounts := make([]string, len(rids))
for i, rid := range(rids) {
accounts[i] = strconv.Itoa(rid)
}
var pushReq *http.Request
if gin.Mode() == "debug" {
pushReq, _ = req.NewPushReq(
&xinge.Request{},
req.Platform(xinge.PlatformiOS),
req.EnvDev(),
req.AudienceType(xinge.AdAccountList),
req.MessageType(xinge.MsgTypeNotify),
req.AccountList(accounts),
req.PushID("0"),
req.Message(xinge.Message{
Title: title,
Content: content,
}),
)
} else {
pushReq, _ = req.NewPushReq(
&xinge.Request{},
req.Platform(xinge.PlatformiOS),
req.AudienceType(xinge.AdAccountList),
req.MessageType(xinge.MsgTypeNotify),
req.AccountList(accounts),
req.PushID("0"),
req.Message(xinge.Message{
Title: title,
Content: content,
}),
)
}
return pushMessage(pushReq, appID, secretKey)
}
func pushMessage(pushReq* http.Request, appID, secretKey string) error {
auther := auth.Auther{AppID: appID, SecretKey: secretKey}
auther.Auth(pushReq)
c := &http.Client{}
rsp, err := c.Do(pushReq)
if err != nil {
log.Error(err)
return err
}
defer rsp.Body.Close()
body, _ := ioutil.ReadAll(rsp.Body)
r := &xinge.CommonRsp{}
json.Unmarshal(body, r)
if r.RetCode != 0 {
msg := fmt.Sprintf("%+v", r)
log.Error(msg)
return errors.New(msg)
}
return nil
}
`
Metadata
Metadata
Assignees
Labels
No labels