Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于IOS AccountList收不到消息 #2

Open
FangJianHust opened this issue Oct 21, 2018 · 2 comments
Open

关于IOS AccountList收不到消息 #2

FangJianHust opened this issue Oct 21, 2018 · 2 comments

Comments

@FangJianHust
Copy link

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

}
`

@bluesky335
Copy link

同样的问题

@Haze-Lan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants