jpush

package
v0.0.0-...-83adff0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CallbackTypeReceive 送达才回执
	CallbackTypeReceive = callbackType(1)
	// CallbackTypeClick 点击才回执
	CallbackTypeClick = callbackType(2)
	// CallbackTypeAll 送达和点击都回执
	CallbackTypeAll = callbackType(3)

	// StatusSwitchOn 回执时候通知栏开关状态:开
	StatusSwitchOn = int(1)
	// StatusSwitchOff 回执时候通知栏开关状态:关
	StatusSwitchOff = int(2)
)
View Source
const (

	// ErrRetry 需要重试
	ErrRetry = int(1030)
	// ErrInternal 服务方内部错误
	ErrInternal = int(1000)
)
View Source
const (
	// AndroidAlertTypeAll 全开
	AndroidAlertTypeAll = -1
	// AndroidAlertTypeNone 全关
	AndroidAlertTypeNone = 0
	// AndroidAlertTypeSound 开声音
	AndroidAlertTypeSound = 1
	// AndroidAlertTypeVibrate 开振动
	AndroidAlertTypeVibrate = 2
	// AndroidAlertTypeLight 开呼吸灯
	AndroidAlertTypeLight = 4

	// AndroidStyleDefault 默认通知栏样式
	AndroidStyleDefault = 0
	// AndroidStyleBigTxt big_text 字段大文本的形式展示
	AndroidStyleBigTxt = 1
	// AndroidStyleInbox inbox 字段 json 的每个 key 对应的 value 会被当作文本条目逐条展示
	AndroidStyleInbox = 2
	// AndroidStylePic big_pic_path 字段的图片URL展示成图片
	AndroidStylePic = 3
)
View Source
const (
	// PlatformIOS .
	PlatformIOS = "ios"
	// PlatformAndroid .
	PlatformAndroid = "android"
	// PlatformWinphone .
	PlatformWinphone = "winphone"
	// PlatformAll .
	PlatformAll = "all"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AndroidNotice

type AndroidNotice struct {
	Alert      string                 `json:"alert"`
	Title      string                 `json:"title,omitempty"`
	AlertType  int                    `json:"alert_type"`
	BuilderID  int                    `json:"builder_id,omitempty"`
	Style      int                    `json:"style,omitempty"`
	BigPicPath string                 `json:"big_pic_path,omitempty"`
	Extras     map[string]interface{} `json:"extras,omitempty"`
}

AndroidNotice .

func (*AndroidNotice) SetPic

func (an *AndroidNotice) SetPic(pic string)

SetPic sets Android notice pic.

type Audience

type Audience struct {
	Object interface{}
	// contains filtered or unexported fields
}

Audience .

func (*Audience) All

func (a *Audience) All()

All .

func (*Audience) SetAlias

func (a *Audience) SetAlias(alias []string)

SetAlias .

func (*Audience) SetID

func (a *Audience) SetID(ids []string)

SetID .

func (*Audience) SetTag

func (a *Audience) SetTag(tags []string)

SetTag .

func (*Audience) SetTagAnd

func (a *Audience) SetTagAnd(tags []string)

SetTagAnd .

type CallbackReply

type CallbackReply struct {
	// Token device token
	Token string `json:"registration_id"`
	// Platform android or ios
	Platform string `json:"platform"`
	// Time 消息送达或点击的秒级时间戳
	Time int64 `json:"sent_time"`
	// Switch 通知栏消息开关
	Switch bool `json:"notification_state"`
	// Type 送达或点击
	Type callbackType `json:"callback_type"`
	// Channel 下发通道
	Channel int `json:"channel"`
	// Params 自定义参数
	Params map[string]string `json:"params"`
}

CallbackReply 消息回执接收体

type CallbackReq

type CallbackReq struct {
	// URL 接受回执数据的URL
	URL string `json:"url"`
	// Type 需要的回执类型
	Type callbackType `json:"type"`
	// Params 携带的自定义参数
	Params map[string]string `json:"params"`
}

CallbackReq 消息回执请求体

func NewCallbackReq

func NewCallbackReq() *CallbackReq

NewCallbackReq new Callback

func (*CallbackReq) SetParam

func (cb *CallbackReq) SetParam(m map[string]string)

SetParam 设置自定义参数

func (*CallbackReq) SetType

func (cb *CallbackReq) SetType(typ callbackType)

SetType 设置需要回执的类型

func (*CallbackReq) SetURL

func (cb *CallbackReq) SetURL(url string)

SetURL 设置接收回执的URL

type Client

type Client struct {
	Auth    string
	Stats   stat.Stat
	Timeout time.Duration
}

Client jpush http client.

func NewClient

func NewClient(appKey, secret string, timeout time.Duration) *Client

NewClient new client.

func (*Client) Push

func (cli *Client) Push(payload *Payload) (res *PushResponse, err error)

Push push notification.

type IOSNotice

type IOSNotice struct {
	Alert            interface{}            `json:"alert"`
	Sound            string                 `json:"sound,omitempty"`
	Badge            string                 `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"`
}

IOSNotice .

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) AddExtras

func (m *Message) AddExtras(key string, value interface{})

AddExtras .

func (*Message) SetContent

func (m *Message) SetContent(c string)

SetContent .

func (*Message) SetContentType

func (m *Message) SetContentType(t string)

SetContentType .

func (*Message) SetTitle

func (m *Message) SetTitle(title string)

SetTitle .

type Notice

type Notice struct {
	Alert    string          `json:"alert,omitempty"`
	Android  *AndroidNotice  `json:"android,omitempty"`
	IOS      *IOSNotice      `json:"ios,omitempty"`
	WINPhone *WinPhoneNotice `json:"winphone,omitempty"`
}

Notice .

func (*Notice) SetAlert

func (n *Notice) SetAlert(alert string)

SetAlert .

func (*Notice) SetAndroidNotice

func (n *Notice) SetAndroidNotice(an *AndroidNotice)

SetAndroidNotice .

func (*Notice) SetIOSNotice

func (n *Notice) SetIOSNotice(in *IOSNotice)

SetIOSNotice .

func (*Notice) SetWinPhoneNotice

func (n *Notice) SetWinPhoneNotice(wn *WinPhoneNotice)

SetWinPhoneNotice .

type Option

type Option struct {
	SendNo             int   `json:"sendno,omitempty"`
	TimeLive           int   `json:"time_to_live,omitempty"`
	ApnsProduction     bool  `json:"apns_production"`
	OverrideMsgID      int64 `json:"override_msg_id,omitempty"`
	BigPushDuration    int   `json:"big_push_duration,omitempty"`
	ReturnInvalidToken bool  `json:"return_invalid_rid,omitempty"` // 是否同步返回无效的token
}

Option .

func (*Option) SetApns

func (o *Option) SetApns(apns bool)

SetApns .

func (*Option) SetBigPushDuration

func (o *Option) SetBigPushDuration(dur int)

SetBigPushDuration .

func (*Option) SetOverrideMsgID

func (o *Option) SetOverrideMsgID(id int64)

SetOverrideMsgID .

func (*Option) SetReturnInvalidToken

func (o *Option) SetReturnInvalidToken(onoff bool)

SetReturnInvalidToken .

func (*Option) SetSendno

func (o *Option) SetSendno(no int)

SetSendno .

func (*Option) SetTimelive

func (o *Option) SetTimelive(timelive int)

SetTimelive .

type Payload

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"`
	Callback     *CallbackReq `json:"callback,omitempty"`
}

Payload .

func NewPayload

func NewPayload() *Payload

NewPayload .

func (*Payload) SetAudience

func (p *Payload) SetAudience(ad *Audience)

SetAudience .

func (*Payload) SetCallbackReq

func (p *Payload) SetCallbackReq(cb *CallbackReq)

SetCallbackReq .

func (*Payload) SetMessage

func (p *Payload) SetMessage(m *Message)

SetMessage .

func (*Payload) SetNotice

func (p *Payload) SetNotice(notice *Notice)

SetNotice .

func (*Payload) SetOptions

func (p *Payload) SetOptions(o *Option)

SetOptions .

func (*Payload) SetPlatform

func (p *Payload) SetPlatform(plat *Platform)

SetPlatform .

func (*Payload) ToBytes

func (p *Payload) ToBytes() ([]byte, error)

ToBytes .

type Platform

type Platform struct {
	OS interface{}
	// contains filtered or unexported fields
}

Platform .

func NewPlatform

func NewPlatform(os ...string) *Platform

NewPlatform .

type PushResponse

type PushResponse struct {
	SendNo        interface{} `json:"sendno,omitempty"`
	MsgID         interface{} `json:"msg_id,omitempty"`
	IllegalTokens []string    `json:"illegal_rids,omitempty"`
	Retry         bool        // 是否需要重试请求
	Error         struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"error,omitempty"`
}

PushResponse .

type WinPhoneNotice

type WinPhoneNotice struct {
	Alert    string                 `json:"alert"`
	Title    string                 `json:"title,omitempty"`
	OpenPage string                 `json:"_open_page,omitempty"`
	Extras   map[string]interface{} `json:"extras,omitempty"`
}

WinPhoneNotice .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL