Documentation
¶
Index ¶
- Variables
- func GetPushID(ctx context.Context) (string, error)
- func GetScheduleID(ctx context.Context) (string, error)
- func Push(ctx context.Context, payload *Payload, callback PushResultHandle) error
- func PushValidate(ctx context.Context, payload *Payload, callback PushResultHandle) error
- func Terminate()
- type AndroidNotification
- func (n *AndroidNotification) SetAlert(alert string) *AndroidNotification
- func (n *AndroidNotification) SetAlertType(alertType int) *AndroidNotification
- func (n *AndroidNotification) SetBigPicPath(bigPicPath string) *AndroidNotification
- func (n *AndroidNotification) SetBigText(bigText string) *AndroidNotification
- func (n *AndroidNotification) SetBuilderID(builderID int) *AndroidNotification
- func (n *AndroidNotification) SetCategory(category string) *AndroidNotification
- func (n *AndroidNotification) SetExtras(extras map[string]interface{}) *AndroidNotification
- func (n *AndroidNotification) SetInbox(inbox map[string]interface{}) *AndroidNotification
- func (n *AndroidNotification) SetPriority(priority int) *AndroidNotification
- func (n *AndroidNotification) SetStyle(style int) *AndroidNotification
- func (n *AndroidNotification) SetTitle(title string) *AndroidNotification
- type Audience
- func (a *Audience) All() *Audience
- func (a *Audience) MarshalJSON() ([]byte, error)
- func (a *Audience) SetAbTest(abtests ...string) *Audience
- func (a *Audience) SetAlias(aliases ...string) *Audience
- func (a *Audience) SetRegistrationID(registrationIDs ...string) *Audience
- func (a *Audience) SetSegment(segments ...string) *Audience
- func (a *Audience) SetTag(tags ...string) *Audience
- func (a *Audience) SetTagAnd(tags ...string) *Audience
- func (a *Audience) SetTagNot(tags ...string) *Audience
- func (a *Audience) SetValue(key string, values ...string) *Audience
- type CIDClient
- type Client
- func (c *Client) GetPushID(ctx context.Context) (string, error)
- func (c *Client) GetScheduleID(ctx context.Context) (string, error)
- func (c *Client) Push(ctx context.Context, payload *Payload, callback PushResultHandle) error
- func (c *Client) PushValidate(ctx context.Context, payload *Payload, callback PushResultHandle) error
- func (c *Client) Terminate()
- type Error
- type ErrorItem
- type HeaderItem
- type IOSNotification
- func (n *IOSNotification) SetAlert(alert interface{}) *IOSNotification
- func (n *IOSNotification) SetBadge(badge interface{}) *IOSNotification
- func (n *IOSNotification) SetCategory(category string) *IOSNotification
- func (n *IOSNotification) SetContentAvailable(contentAvailable bool) *IOSNotification
- func (n *IOSNotification) SetExtras(extras map[string]interface{}) *IOSNotification
- func (n *IOSNotification) SetMutableContent(mutableContent bool) *IOSNotification
- func (n *IOSNotification) SetSound(sound string) *IOSNotification
- type Message
- type Notification
- func (n *Notification) SetAlert(alert string) *Notification
- func (n *Notification) SetAndroidNotification(android *AndroidNotification) *Notification
- func (n *Notification) SetIOSNotification(ios *IOSNotification) *Notification
- func (n *Notification) SetWinPhoneNotification(winPhone *WinPhoneNotification) *Notification
- type OS
- type Option
- type Options
- func (o *Options) SetApnsCollapseID(apnsCollapseID string) *Options
- func (o *Options) SetApnsProduction(prod bool) *Options
- func (o *Options) SetBigPushDuration(bigPushDuration int) *Options
- func (o *Options) SetOverrideMsgID(overrideMsgID int64) *Options
- func (o *Options) SetSendNO(sendNO int) *Options
- func (o *Options) SetTimeLive(timeLive int) *Options
- type Payload
- type Platform
- type PushResult
- type PushResultHandle
- type SmsMessage
- type WinPhoneNotification
- func (n *WinPhoneNotification) SetAlert(alert string) *WinPhoneNotification
- func (n *WinPhoneNotification) SetExtras(extras map[string]interface{}) *WinPhoneNotification
- func (n *WinPhoneNotification) SetOpenPage(openPage string) *WinPhoneNotification
- func (n *WinPhoneNotification) SetTitle(title string) *WinPhoneNotification
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidCID 无效的cid ErrInvalidCID = errors.New("invalid cid") )
Functions ¶
func Push ¶
func Push(ctx context.Context, payload *Payload, callback PushResultHandle) error
Push 消息推送
func PushValidate ¶
func PushValidate(ctx context.Context, payload *Payload, callback PushResultHandle) error
PushValidate 先校验,再推送
Types ¶
type AndroidNotification ¶
type AndroidNotification struct { Alert string `json:"alert"` Title string `json:"title,omitempty"` BuilderID int `json:"builder_id,omitempty"` Priority int `json:"priority,omitempty"` Category string `json:"category,omitempty"` Style int `json:"style,omitempty"` AlertType int `json:"alert_type,omitempty"` BigText string `json:"big_text,omitempty"` Inbox map[string]interface{} `json:"inbox,omitempty"` BigPicPath string `json:"big_pic_path,omitempty"` Extras map[string]interface{} `json:"extras,omitempty"` }
AndroidNotification Android 平台上的通知
func NewAndroidNotification ¶
func NewAndroidNotification() *AndroidNotification
NewAndroidNotification 创建 Android 平台上的通知实例
func (*AndroidNotification) SetAlert ¶
func (n *AndroidNotification) SetAlert(alert string) *AndroidNotification
SetAlert 通知内容
func (*AndroidNotification) SetAlertType ¶
func (n *AndroidNotification) SetAlertType(alertType int) *AndroidNotification
SetAlertType 通知提醒方式
func (*AndroidNotification) SetBigPicPath ¶
func (n *AndroidNotification) SetBigPicPath(bigPicPath string) *AndroidNotification
SetBigPicPath 大图片通知栏样式
func (*AndroidNotification) SetBigText ¶
func (n *AndroidNotification) SetBigText(bigText string) *AndroidNotification
SetBigText 大文本通知栏样式
func (*AndroidNotification) SetBuilderID ¶
func (n *AndroidNotification) SetBuilderID(builderID int) *AndroidNotification
SetBuilderID 通知栏样式 ID
func (*AndroidNotification) SetCategory ¶
func (n *AndroidNotification) SetCategory(category string) *AndroidNotification
SetCategory 通知栏条目过滤或排序
func (*AndroidNotification) SetExtras ¶
func (n *AndroidNotification) SetExtras(extras map[string]interface{}) *AndroidNotification
SetExtras 扩展字段
func (*AndroidNotification) SetInbox ¶
func (n *AndroidNotification) SetInbox(inbox map[string]interface{}) *AndroidNotification
SetInbox 文本条目通知栏样式
func (*AndroidNotification) SetPriority ¶
func (n *AndroidNotification) SetPriority(priority int) *AndroidNotification
SetPriority 通知栏展示优先级
func (*AndroidNotification) SetStyle ¶
func (n *AndroidNotification) SetStyle(style int) *AndroidNotification
SetStyle 通知栏样式类型
func (*AndroidNotification) SetTitle ¶
func (n *AndroidNotification) SetTitle(title string) *AndroidNotification
SetTitle 通知标题
type Audience ¶
Audience 推送目标
func (*Audience) MarshalJSON ¶
MarshalJSON 实现 JSON 接口
func (*Audience) SetRegistrationID ¶
SetRegistrationID 设定注册 ID
func (*Audience) SetSegment ¶
SetSegment 设定用户分群 ID
type CIDClient ¶
type CIDClient struct {
// contains filtered or unexported fields
}
CIDClient 推送唯一标识符客户端
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 推送客户端
func (*Client) GetScheduleID ¶
GetScheduleID 获取定时ID
func (*Client) PushValidate ¶
func (c *Client) PushValidate(ctx context.Context, payload *Payload, callback PushResultHandle) error
PushValidate 先校验,再推送
type Error ¶
type Error struct { StatusCode int `json:"status_code"` ErrorItem *ErrorItem `json:"error,omitempty"` HeaderItem *HeaderItem `json:"header,omitempty"` }
Error 错误
type HeaderItem ¶
type HeaderItem struct { XRateLimitQuota int `json:"X-Rate-Limit-Quota"` XRateLimitRemaining int `json:"X-Rate-Limit-Remaining"` XRateLimitReset int `json:"X-Rate-Limit-Reset"` }
HeaderItem 响应头
type IOSNotification ¶
type IOSNotification struct { Alert interface{} `json:"alert"` Sound string `json:"sound,omitempty"` Badge interface{} `json:"badge,omitempty"` ContentAvailable bool `json:"content-available,omitempty"` MutableContent bool `json:"mutable-content,omitempty"` Category string `json:"category,omitempty"` Extras map[string]interface{} `json:"extras,omitempty"` }
IOSNotification iOS 平台上 APNs 通知结构
func NewIOSNotification ¶
func NewIOSNotification() *IOSNotification
NewIOSNotification 创建 iOS 平台上的通知实例
func (*IOSNotification) SetAlert ¶
func (n *IOSNotification) SetAlert(alert interface{}) *IOSNotification
SetAlert 通知内容
func (*IOSNotification) SetBadge ¶
func (n *IOSNotification) SetBadge(badge interface{}) *IOSNotification
SetBadge 应用角标
func (*IOSNotification) SetCategory ¶
func (n *IOSNotification) SetCategory(category string) *IOSNotification
SetCategory 通知栏条目过滤或排序
func (*IOSNotification) SetContentAvailable ¶
func (n *IOSNotification) SetContentAvailable(contentAvailable bool) *IOSNotification
SetContentAvailable 推送唤醒
func (*IOSNotification) SetExtras ¶
func (n *IOSNotification) SetExtras(extras map[string]interface{}) *IOSNotification
SetExtras 扩展字段
func (*IOSNotification) SetMutableContent ¶
func (n *IOSNotification) SetMutableContent(mutableContent bool) *IOSNotification
SetMutableContent 通知扩展
func (*IOSNotification) SetSound ¶
func (n *IOSNotification) SetSound(sound string) *IOSNotification
SetSound 通知提示声音
type Message ¶
type Message struct { Content string `json:"msg_content"` Title string `json:"title,omitempty"` ContentType string `json:"content_type,omitempty"` Extras map[string]interface{} `json:"extras,omitempty"` }
Message 自定义消息
func (*Message) SetContent ¶
SetContent 消息内容本身
func (*Message) SetContentType ¶
SetContentType 消息内容类型
type Notification ¶
type Notification struct { Alert string `json:"alert,omitempty"` Android *AndroidNotification `json:"android,omitempty"` IOS *IOSNotification `json:"ios,omitempty"` WinPhone *WinPhoneNotification `json:"winphone,omitempty"` }
Notification 通知
func (*Notification) SetAlert ¶
func (n *Notification) SetAlert(alert string) *Notification
SetAlert 设定通知内容
func (*Notification) SetAndroidNotification ¶
func (n *Notification) SetAndroidNotification(android *AndroidNotification) *Notification
SetAndroidNotification 设定 Android 平台上的通知
func (*Notification) SetIOSNotification ¶
func (n *Notification) SetIOSNotification(ios *IOSNotification) *Notification
SetIOSNotification 设定 iOS 平台上的通知
func (*Notification) SetWinPhoneNotification ¶
func (n *Notification) SetWinPhoneNotification(winPhone *WinPhoneNotification) *Notification
SetWinPhoneNotification 设定 Windows Phone 平台上的通知
type Option ¶
type Option func(o *options)
Option 配置项
func SetMasterSecret ¶
SetMasterSecret 设定 MasterSecret
type Options ¶
type Options struct { SendNO int `json:"sendno,omitempty"` TimeLive int `json:"time_to_live,omitempty"` OverrideMsgID int64 `json:"override_msg_id,omitempty"` ApnsProduction bool `json:"apns_production"` ApnsCollapseID string `json:"apns_collapse_id,omitempty"` BigPushDuration int `json:"big_push_duration,omitempty"` }
Options 可选参数
func (*Options) SetApnsCollapseID ¶
SetApnsCollapseID 要覆盖的消息 ID
func (*Options) SetApnsProduction ¶
SetApnsProduction 设定 APNs 是否生产环境
func (*Options) SetBigPushDuration ¶
SetBigPushDuration 定速推送时长(分钟)
func (*Options) SetOverrideMsgID ¶
SetOverrideMsgID 要覆盖的消息 ID
func (*Options) SetTimeLive ¶
SetTimeLive 离线消息保留时长(秒)
type Payload ¶
type Payload struct { Platform *Platform `json:"platform"` // 推送平台 Audience *Audience `json:"audience"` // 推送目标 Notification *Notification `json:"notification,omitempty"` // 通知 Message *Message `json:"message,omitempty"` // 自定义消息 SmsMessage *SmsMessage `json:"sms_message,omitempty"` // 短信补充 Options *Options `json:"options,omitempty"` // 可选参数 CID string `json:"cid,omitempty"` // 推送唯一标识符 }
Payload 推送载荷
type PushResult ¶
PushResult 推送响应结果
func (*PushResult) String ¶
func (r *PushResult) String() string
type PushResultHandle ¶
type PushResultHandle func(context.Context, *PushResult, error)
PushResultHandle 异步响应结果
type SmsMessage ¶
type SmsMessage struct { TempPara interface{} `json:"temp_para,omitempty"` TempID int64 `json:"temp_id"` DelayTime int `json:"delay_time"` }
SmsMessage 短信补充
func (*SmsMessage) SetDelayTime ¶
func (m *SmsMessage) SetDelayTime(delayTime int) *SmsMessage
SetDelayTime 单位为秒,不能超过 24 小时。设置为 0,表示立即发送短信。该参数仅对 android 和 iOS 平台有效,Winphone 平台则会立即发送短信。
func (*SmsMessage) SetTempID ¶
func (m *SmsMessage) SetTempID(tempID int64) *SmsMessage
SetTempID 短信补充的内容模板 ID。没有填写该字段即表示不使用短信补充功能
func (*SmsMessage) SetTempPara ¶
func (m *SmsMessage) SetTempPara(tempPara interface{}) *SmsMessage
SetTempPara 短信模板中的参数
type WinPhoneNotification ¶
type WinPhoneNotification struct { Alert string `json:"alert"` Title string `json:"title,omitempty"` OpenPage string `json:"_open_page,omitempty"` Extras map[string]interface{} `json:"extras,omitempty"` }
WinPhoneNotification Windows Phone 平台上的通知
func NewWinPhoneNotification ¶
func NewWinPhoneNotification() *WinPhoneNotification
NewWinPhoneNotification 创建 Windows Phone 平台上的通知实例
func (*WinPhoneNotification) SetAlert ¶
func (n *WinPhoneNotification) SetAlert(alert string) *WinPhoneNotification
SetAlert 通知内容
func (*WinPhoneNotification) SetExtras ¶
func (n *WinPhoneNotification) SetExtras(extras map[string]interface{}) *WinPhoneNotification
SetExtras 扩展字段
func (*WinPhoneNotification) SetOpenPage ¶
func (n *WinPhoneNotification) SetOpenPage(openPage string) *WinPhoneNotification
SetOpenPage 点击打开的页面名称
func (*WinPhoneNotification) SetTitle ¶
func (n *WinPhoneNotification) SetTitle(title string) *WinPhoneNotification
SetTitle 通知标题