xinge icon indicating copy to clipboard operation
xinge copied to clipboard

关于IOS AccountList收不到消息

Open FangJianHust opened this issue 6 years ago • 2 comments

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

} `

FangJianHust avatar Oct 21 '18 14:10 FangJianHust

同样的问题

bluesky335 avatar Aug 22 '19 11:08 bluesky335

IOS: &xinge.IOSParams{
			Custom: message.Params,
			Aps: &xinge.Aps{
				Alert: map[string]string{
					"title":   message.Params["title"],
					"content": message.Content,
				},
				Badge: 1,
				Sound: "default",
			},
		},

Haze-Lan avatar Dec 13 '19 07:12 Haze-Lan