yeeJpush

package
v0.0.0-...-89bd919 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TAG     = "tag"
	TAG_AND = "tag_and"
	ALIAS   = "alias"
	ID      = "registration_id"
)
View Source
const (
	SUCCESS_FLAG           = "msg_id"
	HOST_NAME_SSL          = "https://api.jpush.cn/v3/push"
	BASE64_TABLE           = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
	VALIDATE_HOST_NAME_SSL = "https://api.jpush.cn/v3/push/validate"
)

Variables

View Source
var NotFoundUser error = errors.New("[Jpush] user not exist")

Functions

This section is empty.

Types

type Audience

type Audience struct {
	Object interface{}
}

func AllAudience

func AllAudience() *Audience

func (*Audience) SetAlias

func (audience *Audience) SetAlias(Object []string)

func (*Audience) SetID

func (audience *Audience) SetID(Object []string)

func (*Audience) SetTag

func (audience *Audience) SetTag(Object []string)

func (*Audience) SetTagAnd

func (audience *Audience) SetTagAnd(Object []string)

type Builder

type Builder struct {
	Platform interface{} `json:"platform"`
	Audience interface{} `json:"audience"`
	Options  Options     `json:"options"`
}

Base Builder

type Client

type Client struct {
	IsIosProduct bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(req NewClientRequest) *Client

func (*Client) PushToAll

func (c *Client) PushToAll(content string) (err error)

func (*Client) PushToOne

func (c *Client) PushToOne(alias, subTitle, content string, extras map[string]interface{}) (err error)

func (*Client) PushToSome

func (c *Client) PushToSome(alias []string, subTitle, content string, extras map[string]interface{}) (err error)

func (*Client) ValidatePushToOne

func (c *Client) ValidatePushToOne(alias, content string) (err error)

func (*Client) ValidatePushToSome

func (c *Client) ValidatePushToSome(alias []string, content string) (err error)

type Message

type Message struct {
	Content     string                 `json:"msg_content"`
	Title       string                 `json:"title"`
	ContentType string                 `json:"content_type"`
	Extras      map[string]interface{} `json:"extras,omitempty"`
}

func (*Message) AddExtras

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

func (*Message) SetContent

func (message *Message) SetContent(c string)

func (*Message) SetContentType

func (message *Message) SetContentType(t string)

func (*Message) SetTitle

func (message *Message) SetTitle(title string)

type MessageAndNoticeBuilder

type MessageAndNoticeBuilder struct {
	Builder
	Notification map[string]interface{} `json:"notification"`
	Message      interface{}            `json:"message"`
}

MessageAndNotice

func NewMessageAndNoticeBuilder

func NewMessageAndNoticeBuilder() *MessageAndNoticeBuilder

func (*MessageAndNoticeBuilder) ClearNotice

func (messageNoticeBuilder *MessageAndNoticeBuilder) ClearNotice()

func (*MessageAndNoticeBuilder) SetAudience

func (messageNoticeBuilder *MessageAndNoticeBuilder) SetAudience(ad *Audience)

func (*MessageAndNoticeBuilder) SetMessage

func (messageNoticeBuilder *MessageAndNoticeBuilder) SetMessage(m *Message)

func (*MessageAndNoticeBuilder) SetNotice

func (messageNoticeBuilder *MessageAndNoticeBuilder) SetNotice(o interface{})

可以为每类Notice设置一个

func (*MessageAndNoticeBuilder) SetOptions

func (messageNoticeBuilder *MessageAndNoticeBuilder) SetOptions(o Options)

func (*MessageAndNoticeBuilder) SetPlatform

func (messageNoticeBuilder *MessageAndNoticeBuilder) SetPlatform(pf *Platform)

type MessageBuilder

type MessageBuilder struct {
	Builder
	Message interface{} `json:"message"`
}

MessageBuilder

func NewMessageBuilder

func NewMessageBuilder() *MessageBuilder

func (*MessageBuilder) SetAudience

func (messageBuilder *MessageBuilder) SetAudience(ad *Audience)

func (*MessageBuilder) SetMessage

func (messageBuilder *MessageBuilder) SetMessage(m *Message)

func (*MessageBuilder) SetOptions

func (messageBuilder *MessageBuilder) SetOptions(o Options)

func (*MessageBuilder) SetPlatform

func (messageBuilder *MessageBuilder) SetPlatform(pf *Platform)

type NewClientRequest

type NewClientRequest struct {
	Name         string //这个客户端的名字
	AppKey       string //
	Secret       string //
	IsIosProduct bool   //如果是否false表示向测试设备推送,如果是true表示向正式设备推送,后台的那个开发与正式似乎没有作用.
}

type Notice

type Notice struct {
	NoticeSimple
	// 这里自定义 JSON 格式的 Key/Value 信息,以供业务使用
	Extras map[string]interface{} `json:"extras,omitempty"`
}

func NewNotice

func NewNotice() *Notice

func (*Notice) AddExtras

func (notice *Notice) AddExtras(key string, value interface{})

type NoticeAndroid

type NoticeAndroid struct {
	Notice
	// 如果指定了,则通知里原来展示 App名称的地方,将展示成这个字段。
	Title string `json:"title"`
	// Android SDK 可设置通知栏样式,这里根据样式 ID 来指定该使用哪套样式。
	BuilderId int `json:"builder_id,omitempty"`
}

func NewNoticeAndroid

func NewNoticeAndroid() *NoticeAndroid

type NoticeBuilder

type NoticeBuilder struct {
	Builder
	Notification map[string]interface{} `json:"notification"`
}

NoticeBuilder

func NewNoticeBuilder

func NewNoticeBuilder() *NoticeBuilder

func (*NoticeBuilder) ClearNotice

func (noticeBuilder *NoticeBuilder) ClearNotice()

func (*NoticeBuilder) SetAudience

func (noticeBuilder *NoticeBuilder) SetAudience(ad *Audience)

func (*NoticeBuilder) SetNotice

func (noticeBuilder *NoticeBuilder) SetNotice(o interface{})

可以为每类Notice设置一个

func (*NoticeBuilder) SetOptions

func (noticeBuilder *NoticeBuilder) SetOptions(o Options)

func (*NoticeBuilder) SetPlatform

func (noticeBuilder *NoticeBuilder) SetPlatform(pf *Platform)

type NoticeIos

type NoticeIos struct {
	Notice
	// 如果无此字段,则此消息无声音提示;有此字段,如果找到了指定的声音就播放该声音,否则播放默认声音,
	// 如果此字段为空字符串,iOS 7 为默认声音,iOS 8 为无声音。
	// (消息) 说明:JPush 官方 API Library (SDK) 会默认填充声音字段。提供另外的方法关闭声音。
	Sound string `json:"sound,omitempty"`
	// 如果不填,表示不改变角标数字;否则把角标数字改为指定的数字;为 0 表示清除。
	// 新增支持 "+1" 功能,详情参考:http://blog.jpush.cn/ios_apns_badge_plus/
	// (消息) 说明:JPush 官方 API Library (SDK) 会默认填充 badge 值为 "+1"。提供另外的方法不变更 badge 值。
	Badge string `json:"badge,omitempty"`
	// 如果为 true 表示要静默推送。
	ContentAvailable bool `json:"content-available"`
	// 设置APNs payload中的"category"字段值。
	// (消息) 说明:ios8才支持该字段。
	Category string `json:"category,omitempty"`
}

func NewNoticeIos

func NewNoticeIos() *NoticeIos

type NoticeSimple

type NoticeSimple struct {
	// 通知的内容在各个平台上,都可能只有这一个最基本的属性 "alert"
	Alert interface{} `json:"alert"`
}

func NewNoticeSimple

func NewNoticeSimple() *NoticeSimple

type NoticeWinphone

type NoticeWinphone struct {
	Notice
	// 会填充到 toast 类型 text1 字段上。
	Title string `json:"title"`
	// 点击打开的页面。会填充到推送信息的 param 字段上,表示由哪个 App 页面打开该通知。可不填,则由默认的首页打开。
	OpenPage string `json:"_open_page,omitempty"`
}

func NewNoticeWinphone

func NewNoticeWinphone() *NoticeWinphone

type Options

type Options map[string]interface{}

func NewOptions

func NewOptions() Options

func (Options) SetApns_production

func (o Options) SetApns_production(apns_production bool)

True 表示推送生产环境,False 表示要推送开发环境; 如果不指定则为推送生产环境。 (消息) JPush 官方 API LIbrary (SDK) 默认设置为推送 “开发环境”。

func (Options) SetBigPushDuration

func (o Options) SetBigPushDuration(big_push_duration int)

又名缓慢推送,把原本尽可能快的推送速度,降低下来,在给定的 n 分钟内,均匀地向这次推送的目标用户推送。最大值为 1440。未设置则不是定速推送。

func (Options) SetOverrideMsgID

func (o Options) SetOverrideMsgID(override_msg_id int64)

如果当前的推送要覆盖之前的一条推送,这里填写前一条推送的 msg_id 就会产生覆盖效果,即:1) 该 msg_id 离线收到的消息是覆盖后的内容;2)即使该 msg_id Android 端用户已经收到, 如果通知栏还未清除,则新的消息内容会覆盖之前这条通知;覆盖功能起作用的时限是:1 天。 如果在覆盖指定时限内该 msg_id 不存在,则返回 1003 错误,提示不是一次有效的消息覆盖操作,当前的消息不会被推送。

func (Options) SetSendNo

func (o Options) SetSendNo(sendno int)

纯粹用来作为 API 调用标识,API 返回时被原样返回,以方便 API 调用方匹配请求与返回。

func (Options) SetTimelive

func (o Options) SetTimelive(time_to_live int)

推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。 默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到。

type Platform

type Platform struct {
	Object interface{}
}

func AllPlatform

func AllPlatform() *Platform

func (*Platform) Add

func (platform *Platform) Add(os PlatformType)

type PlatformType

type PlatformType string
const (
	IOS      PlatformType = "ios"
	ANDROID  PlatformType = "android"
	WINPHONE PlatformType = "winphone"
)

type PushClient

type PushClient struct {
	MasterSecret string
	AppKey       string
	AuthCode     string
	BaseUrl      string
}

func NewPushClient

func NewPushClient(secret, appKey string) *PushClient

func (*PushClient) Send

func (pushClient *PushClient) Send(builder interface{}) (*common.RetData, error)

func (*PushClient) SendPushBytes

func (pushClient *PushClient) SendPushBytes(content []byte) (ret *common.RetData, err error)

func (*PushClient) SendPushString

func (pushClient *PushClient) SendPushString(content string) (ret *common.RetData, err error)

func (*PushClient) SendValidate

func (pushClient *PushClient) SendValidate(builder interface{}) (*common.RetData, error)

func (*PushClient) SendValidatePushBytes

func (pushClient *PushClient) SendValidatePushBytes(content []byte) (ret *common.RetData, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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