Documentation ¶
Index ¶
- Constants
- Variables
- type Access
- type Action
- type Body
- type Callback
- type CallbackItem
- type Client
- type Ext
- type Hps
- type InvalidTokenResponse
- type Message
- func (m *Message) JSON() (res string, err error)
- func (m *Message) SetBiTag(tag string) *Message
- func (m *Message) SetContent(content string) *Message
- func (m *Message) SetCustomize(key, val string) *Message
- func (m *Message) SetIcon(url string) *Message
- func (m *Message) SetIntent(intent string) *Message
- func (m *Message) SetMsgType(typ int) *Message
- func (m *Message) SetPkg(pkg string) *Message
- func (m *Message) SetTitle(title string) *Message
- type Msg
- type Param
- type Response
Constants ¶
const ( // ResponseCodeSuccess success code ResponseCodeSuccess = "80000000" // ResponseCodeSomeTokenInvalid some tokens failed ResponseCodeSomeTokenInvalid = "80100000" // ResponseCodeAllTokenInvalid all tokens failed ResponseCodeAllTokenInvalid = "80100002" // ResponseCodeAllTokenInvalidNew . ResponseCodeAllTokenInvalidNew = "80300007" )
const ( // MsgTypePassthrough 消息类型:透传 MsgTypePassthrough = 1 // MsgTypeNotification 消息类型:通知栏消息 MsgTypeNotification = 3 // ActionTypeCustom 动作类型:自定义 ActionTypeCustom = 1 // ActionTypeURL 动作类型:打开URL ActionTypeURL = 2 // ActionTypeAPP 动作类型:打开APP ActionTypeAPP = 3 // CallbackTokenUninstalled 应用被卸载了 CallbackTokenUninstalled = 2 // CallbackTokenNotApply 终端安装了该应用,但从未打开过,未申请token,所以不能展示 CallbackTokenNotApply = 5 // CallbackTokenInactive 非活跃设备,消息丢弃 CallbackTokenInactive = 10 )
Variables ¶
var ( // ErrLimit . ErrLimit = errors.New("触发华为系统级流控") )
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback struct {
Statuses []*CallbackItem `json:"statuses"`
}
Callback 华为推送回执(回调)
type CallbackItem ¶
type CallbackItem struct { BiTag string `json:"biTag"` AppID string `json:"appid"` Token string `json:"token"` Status int `json:"status"` Timestamp int64 `json:"timestamp"` }
CallbackItem http://developer.huawei.com/consumer/cn/service/hms/catalog/huaweipush_agent.html?page=hmssdk_huaweipush_devguide_server_agent#3.3 消息回执
type Client ¶
type Client struct { Access *Access HTTPClient *http.Client Stats stat.Stat SDKCtx string Package string }
Client huawei push http client.
func (*Client) Push ¶
func (c *Client) Push(payload *Message, tokens []string, expire time.Time) (response *Response, err error)
Push push notifications. access_token: 必选,使用OAuth2进行鉴权时的ACCESSTOKEN nsp_ts: 必选,服务请求时间戳,自GMT 时间 1970-1-1 0:0:0至今的秒数。如果传入的时间与服务器时间相 差5分钟以上,服务器可能会拒绝请求。 nsp_svc: 必选, 本接口固定为openpush.message.api.send device_token_list: 以半角逗号分隔的华为PUSHTOKEN列表,单次最多只是1000个 expire_time: 格式ISO 8601[6]:2013-06-03T17:30,采用本地时间精确到分钟 payload: 描述投递消息的JSON结构体,描述PUSH消息的:类型、内容、显示、点击动作、报表统计和扩展信 息。具体参考下面的详细说明。
type Ext ¶
type Ext struct { BiTag string `json:"biTag"` Icon string `json:"icon"` Customize []map[string]string `json:"customize"` }
Ext .
type InvalidTokenResponse ¶
type InvalidTokenResponse struct { Success int `json:"success"` Failure int `json:"failure"` IllegalTokens []string `json:"illegal_tokens"` }
InvalidTokenResponse invalid tokens info in the push response.
type Message ¶
type Message struct {
Hps Hps `json:"hps"`
}
Message request message.
func (*Message) SetContent ¶
SetContent sets content.
func (*Message) SetCustomize ¶
SetCustomize set ext info.