Giter Site home page Giter Site logo

xinge's People

Contributors

frontmage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fangj99 xingepush

xinge's Issues

关于IOS AccountList收不到消息

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

}
`

badge问题

// Aps 通知栏iOS消息的aps字段,详情请参照苹果文档
type Aps struct {
Alert map[string]string json:"alert,omitempty"
Badge int json:"badge,omitempty"
Category string json:"category,omitempty"
ContentAvailable int json:"content-available,omitempty"
Sound string json:"sound,omitempty"
}

Badge 应该对应badge_type,应该参考腾讯信鸽文档。如果写成badge角标没反应

关于ios自定义参数的问题

我的使用安卓推送没有问题,但是使用ios推送,收不到自定义的消息,在后台历史推送里面也看不到

这是我的代码
auther := auth.Auther{AppID: "", SecretKey: ""}
pushReq, _ = req.NewPushReq(
&xinge.Request{},
req.Platform(xinge.PlatformiOS),
req.EnvDev(),
req.AudienceType(xinge.AdToken),
req.MessageType(xinge.MsgTypeNotify),
req.TokenList([]string{NotificationId}),
req.PushID("0"),
req.Message(xinge.Message{
Title: "",
Content: "",
Android: &xinge.AndroidParams{},
IOS: &xinge.IOSParams{},
}),
req.CustomContent(custom),
)
custom 是一个map[string]string
代码基本和安卓的一模一样

demo会panic

因为 http.Client.Do() 的错误没有处理, 直接defer Close() 了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.