Files
ylywyn eb0b869f6b 更新,完全支持V3
更新,完全支持V3
2015-07-04 02:23:52 +08:00

50 lines
963 B
Go

package jpushclient
import (
"encoding/json"
)
type PayLoad struct {
Platform interface{} `json:"platform"`
Audience interface{} `json:"audience"`
Notification interface{} `json:"notification,omitempty"`
Message interface{} `json:"message,omitempty"`
Options *Option `json:"options,omitempty"`
}
func NewPushPayLoad() *PayLoad {
pl := &PayLoad{}
o := &Option{}
o.ApnsProduction = false
pl.Options = o
return pl
}
func (this *PayLoad) SetPlatform(pf *Platform) {
this.Platform = pf.Os
}
func (this *PayLoad) SetAudience(ad *Audience) {
this.Audience = ad.Object
}
func (this *PayLoad) SetOptions(o *Option) {
this.Options = o
}
func (this *PayLoad) SetMessage(m *Message) {
this.Message = m
}
func (this *PayLoad) SetNotice(notice *Notice) {
this.Notification = notice
}
func (this *PayLoad) ToBytes() ([]byte, error) {
content, err := json.Marshal(this)
if err != nil {
return nil, err
}
return content, nil
}