jpush

package module
v0.0.0-...-3dc91f5 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2015 License: GPL-2.0 Imports: 3 Imported by: 0

README

jpush

jpush api for golang

概述

这是JPush REST API 的 go 版本封装开发包,仅支持最新的REST API v3功能。 REST API 文档:http://docs.jpush.cn/display/dev/Push-API-v3 对所有官方支持的API都进行了封装

使用

go get https://github.com/isdamir/jpush

然后请参照example/example.go使用

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+/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Audience

type Audience struct {
	Object interface{}
}

func AllAudience

func AllAudience() *Audience

func NewAudience

func NewAudience() *Audience

func (*Audience) SetAlias

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

func (*Audience) SetID

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

func (*Audience) SetTag

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

func (*Audience) SetTagAnd

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

type Builder

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

Base Builder

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 (this *Message) AddExtras(key string, value interface{})

func (*Message) SetContent

func (this *Message) SetContent(c string)

func (*Message) SetContentType

func (this *Message) SetContentType(t string)

func (*Message) SetTitle

func (this *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

------------------MessageAndNoticeBuilder------------------

func (*MessageAndNoticeBuilder) ClearNotice

func (this *MessageAndNoticeBuilder) ClearNotice()

func (*MessageAndNoticeBuilder) SetAudience

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

func (*MessageAndNoticeBuilder) SetMessage

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

func (*MessageAndNoticeBuilder) SetNotice

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

可以为每类Notice设置一个

func (*MessageAndNoticeBuilder) SetOptions

func (this *MessageAndNoticeBuilder) SetOptions(o *Options)

func (*MessageAndNoticeBuilder) SetPlatform

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

type MessageBuilder

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

MessageBuilder

func NewMessageBuilder

func NewMessageBuilder() *MessageBuilder

---------------------MessageBuilder --------------------

func (*MessageBuilder) SetAudience

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

func (*MessageBuilder) SetMessage

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

func (*MessageBuilder) SetOptions

func (this *MessageBuilder) SetOptions(o *Options)

func (*MessageBuilder) SetPlatform

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

type Notice

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

func (*Notice) AddExtras

func (this *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

---------------------NoticeBuilder----------------------

func (*NoticeBuilder) ClearNotice

func (this *NoticeBuilder) ClearNotice()

func (*NoticeBuilder) SetAudience

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

func (*NoticeBuilder) SetNotice

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

可以为每类Notice设置一个

func (*NoticeBuilder) SetOptions

func (this *NoticeBuilder) SetOptions(o *Options)

func (*NoticeBuilder) SetPlatform

func (this *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 string `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 struct {
	/*
		纯粹用来作为 API 调用标识,API 返回时被原样返回,以方便 API 调用方匹配请求与返回。
	*/
	Sendno int `json:"sendno,omitempty"`
	/*
		推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。默认 86400 (1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到。
	*/
	Timelive int `json:"time_to_live,omitempty"`
	/*
		True 表示推送生产环境,False 表示要推送开发环境; 如果不指定则为推送生产环境。

		(消息) JPush 官方 API LIbrary (SDK) 默认设置为推送 “开发环境”。
	*/
	Apns_production bool `json:"apns_production"`
	/*
		如果当前的推送要覆盖之前的一条推送,这里填写前一条推送的 msg_id 就会产生覆盖效果,即:1)该 msg_id 离线收到的消息是覆盖后的内容;2)即使该 msg_id Android 端用户已经收到,如果通知栏还未清除,则新的消息内容会覆盖之前这条通知;覆盖功能起作用的时限是:1 天。
		如果在覆盖指定时限内该 msg_id 不存在,则返回 1003 错误,提示不是一次有效的消息覆盖操作,当前的消息不会被推送。
	*/
	OverrideMsgID float32 `json:"override_msg_id,omitempty"`
	/*
		又名缓慢推送,把原本尽可能快的推送速度,降低下来,在给定的 n 分钟内,均匀地向这次推送的目标用户推送。最大值为 1440。未设置则不是定速推送。
	*/
	BigPushDuration int `json:"big_push_duration,omitempty"`
}

func NewOptions

func NewOptions() *Options

type Platform

type Platform struct {
	Object interface{}
}

func AllPlatform

func AllPlatform() *Platform

func NewAndroid

func NewAndroid() *Platform

func NewIOS

func NewIOS() *Platform

func NewPlatform

func NewPlatform() *Platform

func (*Platform) Add

func (this *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 (this *PushClient) Send(builder interface{}) (*common.RetData, error)

func (*PushClient) SendPushBytes

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

func (*PushClient) SendPushString

func (this *PushClient) SendPushString(content string) (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