代码拉取完成,页面将自动刷新
package jpush
import "encoding/json"
type PayLoad struct {
Platform *Platform `json:"platform"` // 平台
Audience *Audience `json:"audience"` // 推送目标
Notification *Notification `json:"notification,omitempty"` // 推送内容
Message *Message `json:"message,omitempty"` // 推送内容
Options *Options `json:"options,omitempty"` // 推送选项
Cid string `json:"cid,omitempty"` // 推送唯一标识符
}
// NewPayLoad 创建一个新的推送对象
func NewPayLoad() *PayLoad {
p := &PayLoad{}
p.Options = &Options{}
p.Options.ApnsProduction = false
return p
}
// SetPlatform 设置平台
func (p *PayLoad) SetPlatform(platform *Platform) {
p.Platform = platform
}
// SetAudience 设置推送目标
func (p *PayLoad) SetAudience(audience *Audience) {
p.Audience = audience
}
// SetNotification 设置推送内容
func (p *PayLoad) SetNotification(notification *Notification) {
p.Notification = notification
}
// SetMessage 设置推送内容
func (p *PayLoad) SetMessage(message *Message) {
p.Message = message
}
// SetOptions 设置推送选项
func (p *PayLoad) SetOptions(options *Options) {
p.Options = options
}
// Bytes 返回推送对象的json字节数组
func (p *PayLoad) Bytes() ([]byte, error) {
payload := struct {
Platform interface{} `json:"platform"`
Audience interface{} `json:"audience"`
Notification *Notification `json:"notification,omitempty"`
Message *Message `json:"message,omitempty"`
Options *Options `json:"options,omitempty"`
Cid string `json:"cid,omitempty"`
}{
Platform: p.Platform.Interface(),
Audience: p.Audience.Interface(),
Notification: p.Notification,
Message: p.Message,
Options: p.Options,
Cid: p.Cid,
}
return json.Marshal(payload)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。