xinge

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

腾讯信鸽Golang SDK(非官方版本)

Go Report Card GoDoc

前言

部分代码来源于信鸽官方推荐的FrontMage
原本想使用FrontMage的库,但不太符合我懒人的习惯,于是自己动手改造一下,分享给大家!

考虑到国内连接GitHub缓慢,代码也同步放在我的码云

更新日志

2019年6月22日 08:46:04
修复按账号推送无效的bug
2019年6月20日 10:43:32
增加OptionAndroidIntent方法

用法

安装
Go modules
gitee.com/kmlixh/xinge v1.0.3
普通方式

$ go get gitee.com/kmlixh/xinge

或者

$ go get github.com/kmlixh/xinge

全局推送
package xinge

import (
	"testing"
	"time"
	"fmt"
	"gitee.com/kmlixh/xinge"
)

var authorAndroid = xinge.Authorization{AppID:"085f557303c8b", SecretKey:"046cf0c53a1bf6683bb22020a0ed8fec"}
var authoriOS = xinge.Authorization{AppID:"d5089ed7c3200", SecretKey:"d46a1b7d9d5327df90519d758cee8a1d"}
var xgClient =xinge.NewXingeClient(authorAndroid,authoriOS,xinge.NewHttpClient())

//测试推送一条面向全员的Notify消息
func main() {
	//以下两个配置信息都是真实的,但是并未配置正确的客户端,此处仅用来测试服务器的返回是否一致
	msg := xinge.NewPushAllNotifyPushMsg(xinge.PlatformAndroid, "测试的标题", "测试的内容"+time.Now().String())
	resp := xgClient.Push(msg)
	fmt.Println(resp)
}
类型解析:
IAuth   //推送鉴权的接口;
Authorization //实现了IAuth接口,提供鉴权的相关操作
XgClient  //信鸽推送的客户端,推送相关的操作都由XgClient完成
IPushMSg //消息抽象接口
PushMsg   //被推送的消息,抽象和封装了推送消息本身。
Platform //平台;字符串的变体。目前只有两个,Android和iOS。这里不禁有人要问,为什么没有全平台?嗯,信鸽就是没有全平台!!!
Audience //推送目标,或者说推送受众。这里有All,tag,token,token_list等等,详细看官方文档。
PushMsgOption //函数模型,用于快速扩展和修改PushMsg的某个属性
//大概介绍这么多
用法解析:
XgClient相关

XgClient作为推送操作的执行者,内部封装了信鸽推送的相关方法和逻辑。

创建XgClient

func NewXingeClient(androidAuth IAuth, iOSAuth IAuth, client *http.Client) XgClient
func NewXingeClient3() XgClient
func NewXingeClientent2(appId string, secretKey string, platform Platform) XgClient

XgClient的用法:

//这个方法用来解析返回的http.Response为通用的返回数据,不多解释
func (xg XgClient) MarshalResp(resp *http.Response) CommonRsp
//推送一条消息
// 这里需要注意的是,这个操作会比对msg中的Platform属性和XgClient自身是否持有相应平台的IAuth
// 如果XgClient没有相应的IAuth,则会抛出异常
func (xg XgClient) Push(msg IPushMsg) CommonRsp
//使用指定的IAuth信息来推送一条消息
func (xg XgClient) PushWithAuthorization(msg IPushMsg, auth IAuth) CommonRsp

//设置Android平台的IAuth信息
func (xg *XgClient) SetAndroidAuth(auth IAuth)
//设置iOS平台的IAuth信息
func (xg *XgClient) SetIOSAuth(auth IAuth)
//直接通过appId,secretKey,以及平台信息来设置某个平台(Android或者iOS)的IAuth
func (xg *XgClient) SetAuth(appId string, secretKey string, platform Platform)

如何创建推送消息?

这里提供了以下一些方法来帮助用户快速创建推送消息:

func DefaultPushMsg(platform Platform, msgType MessageType, title string, content string) IPushMsg
func NewAccountNotifyPushMsg(platform Platform, title string, content string, accounts ...string) IPushMsg
func NewAccountPushMsg(platform Platform, msgType MessageType, title string, content string, accounts ...string) IPushMsg
func NewPushAllNotifyPushMsg(platform Platform, title string, content string) IPushMsg
func NewPushAllPushMsg(platform Platform, msgType MessageType, title string, content string) IPushMsg
func NewTagNotifyPushMsg(platform Platform, title string, content string, tagOpt TagOperation, tags ...string) IPushMsg
func NewTagPushMsg(platform Platform, msgType MessageType, title string, content string, tagOpt TagOperation, tags ...string) IPushMsg
func NewTokenNotifyPushMsg(platform Platform, title string, content string, tokens ...string) IPushMsg
func NewTokenPushMsg(platform Platform, msgType MessageType, title string, content string, tokens ...string) IPushMsg

包括了所有推送类型的推送方法,需要重点说明的是,token和tokenlist,account和account_list的类型区分,都是依靠末尾的不定长度的参数个数决定的!

例如:只传递一个token进入NewTokenPushMsg函数,则类型为token,如果为多个,则为token_list。account同理!

重点说明:对于token_list和account_list类型的推送,如果推送数量超过1000,理论上会自动轮询推送,不需要再手动处理!请知悉!

如何修改推送的消息?

两种方法:

1.手动修改;
2.借助PushMsgOption进行修改;

第一种略过,我们说第二种,PushMsg具有一个非常好用的方法:

func (rst *PushMsg) RenderOptions(opts ...PushMsgOption) error

这个方法能使用PushMsgOption对象来修改自身的属性。详细请看源码实现!!!

如何创建PushMsgOption?

结合FrontMage大神写一些东西,做了修改和补充后,具有以下规模:

func OptionAccountList(al ...string) PushMsgOption
func OptionAccountListAdd(a string) PushMsgOption
func OptionAccountType(at int) PushMsgOption
func OptionAddAction(k string, v interface{}) PushMsgOption
func OptionAndroidParams(params *AndroidParams) PushMsgOption
func OptionAps(aps *Aps) PushMsgOption
func OptionApsAlert(alert Alert) PushMsgOption
func OptionApsBadage(badge int) PushMsgOption
func OptionApsCategory(category string) PushMsgOption
func OptionApsContentAvailable(contentAvailable int) PushMsgOption
func OptionApsSound(sound string) PushMsgOption
func OptionApsThreadId(threadId string) PushMsgOption
func OptionBuilderID(id int) PushMsgOption
func OptionCleanable(c int) PushMsgOption
func OptionContent(c string) PushMsgOption
func OptionCustomContent(ct map[string]string) PushMsgOption
func OptionCustomContentSet(k, v string) PushMsgOption
func OptionEnvDevelop() PushMsgOption
func OptionEnvProduction() PushMsgOption
func OptionExpireTime(et time.Time) PushMsgOption
func OptionIOSParams(params *IOSParams) PushMsgOption
func OptionIconRes(ir string) PushMsgOption
func OptionIconType(it int) PushMsgOption
func OptionLights(l int) PushMsgOption
func OptionLoopTimes(lt int) PushMsgOption
func OptionMessage(m Message) PushMsgOption
func OptionMessageType(t MessageType) PushMsgOption
func OptionMultiPkg(mp bool) PushMsgOption
func OptionNID(id int) PushMsgOption
func OptionPlatAndroid() PushMsgOption
func OptionPlatIos() PushMsgOption
func OptionPlatform(p Platform) PushMsgOption
func OptionPushID(pid string) PushMsgOption
func OptionRing(ring int) PushMsgOption
func OptionRingRaw(rr string) PushMsgOption
func OptionSendTime(st time.Time) PushMsgOption
func OptionSeq(s int64) PushMsgOption
func OptionSmallIcon(si int) PushMsgOption
func OptionStatTag(st string) PushMsgOption
func OptionStyleID(s int) PushMsgOption
func OptionTagList(op TagOperation, tags ...string) PushMsgOption
func OptionTagListOpt2(tl TagList) PushMsgOption
func OptionTitle(t string) PushMsgOption
func OptionTokenList(tl ...string) PushMsgOption
func OptionTokenListAdd(t string) PushMsgOption
func OptionVibrate(v int) PushMsgOption

基本上已经包含了所有可以修改的部分,具体每一个函数用来修改那一块,可以看源码,源码中都有注释!!!

特别说明:

修改和扩充了Alert对象,给Alert增加了一些操作方法。详细的请涉及到苹果推送的同学自己尝试(没有苹果开发者证书,这块没法做测试,sorry)

type Alert map[string]interface{}
func (alert Alert) Set(key string, value interface{})
func (alert Alert) SetActionLocKey(data string)
func (alert Alert) SetBody(content string)
func (alert Alert) SetLaunchImage(data string)
func (alert Alert) SetLocArgs(data []string)
func (alert Alert) SetLocKey(data string)
func (alert Alert) SetTitle(title string)
func (alert Alert) SetTitleLocArgs(data []string)
func (alert Alert) SetTitleLocKey(data string)

几个或许有用处的方法:

func DefaultApsAlert(title string, body string) Alert

func DefaultIOSParams(title string, content string) *IOSParams

func DefaultAndroidParams() *AndroidParams

func DefaultPushMsg(platform Platform, msgType MessageType, title string, content string) IPushMsg

相应的,如果想看特别详细的代码文档,点击文档顶部的godoc图标,或者是下面的图标

Go Report Card GoDoc

捐助作者
   

Documentation

Index

Constants

This section is empty.

Variables

View Source
var XingeURL = "https://openapi.xg.qq.com/v3/push/app"

XingeURL 信鸽API地址

Functions

func MakeAuthHeader

func MakeAuthHeader(appID, secretKey string) string

MakeAuthHeader 生成信鸽推送鉴权串

func NewHttpClient

func NewHttpClient() *http.Client

NewHttpClient 创建一个默认的http.client

func PushURL

func PushURL(url string)

PushURL 修改信鸽的请求URL

Types

type Alert

type Alert map[string]interface{}

Alert 自定义Alert的数据类型

func DefaultApsAlert

func DefaultApsAlert(title string, body string) Alert

DefaultApsAlert 创建默认的Alert

func (Alert) Set

func (alert Alert) Set(key string, value interface{})

Set 设置Key-Value

func (Alert) SetActionLocKey

func (alert Alert) SetActionLocKey(data string)

SetActionLocKey 设置相关属性

func (Alert) SetBody

func (alert Alert) SetBody(content string)

SetBody 设置提示详情

func (Alert) SetLaunchImage

func (alert Alert) SetLaunchImage(data string)

SetLaunchImage 设置相关属性

func (Alert) SetLocArgs

func (alert Alert) SetLocArgs(data []string)

SetLocArgs 设置相关属性

func (Alert) SetLocKey

func (alert Alert) SetLocKey(data string)

SetLocKey 设置相关属性

func (Alert) SetTitle

func (alert Alert) SetTitle(title string)

SetTitle 设置标题

func (Alert) SetTitleLocArgs

func (alert Alert) SetTitleLocArgs(data []string)

SetTitleLocArgs 设置相关属性

func (Alert) SetTitleLocKey

func (alert Alert) SetTitleLocKey(data string)

SetTitleLocKey 设置相关属性

type AndroidParams

type AndroidParams struct {
	NID           int                    `json:"n_id,omitempty"`
	BuilderID     int                    `json:"builder_id,omitempty"`
	Ring          int                    `json:"ring,omitempty"`
	RingRaw       string                 `json:"ring_raw,omitempty"`
	Vibrate       int                    `json:"vibrate,omitempty"`
	Lights        int                    `json:"lights,omitempty"`
	Cleanable     int                    `json:"clearable,omitempty"`
	IconType      int                    `json:"icon_type,omitempty"`
	IconRes       string                 `json:"icon_res,omitempty"`
	StyleID       int                    `json:"style_id,omitempty"`
	SmallIcon     int                    `json:"small_icon,omitempty"`
	Action        map[string]interface{} `json:"action,omitempty"`
	CustomContent map[string]string      `json:"custom_content,omitempty"`
}

AndroidParams 安卓push参数

func DefaultAndroidParams

func DefaultAndroidParams() *AndroidParams

DefaultAndroidParams 默认的Android推送参数

type Aps

type Aps struct {
	Alert            `json:"alert,omitempty"`
	Badge            int    `json:"badge,omitempty"`
	Category         string `json:"category,omitempty"`
	ContentAvailable int    `json:"content-available,omitempty"`
	Sound            string `json:"sound,omitempty"`
	ThreadId         string `json:"thread_id,omitempty"`
}

Aps 通知栏iOS消息的aps字段,详情请参照苹果文档 https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW1

func DefaultAps

func DefaultAps(title string, content string) *Aps

DefaultAps 创建默认的Aps

type AudienceType

type AudienceType string

AudienceType 推送目标

const (
	// AudienceTypeAll 全量推送
	AudienceTypeAll AudienceType = "all"
	// AudienceTypeTag 标签推送
	AudienceTypeTag AudienceType = "tag"
	// AudienceTypeToken  单设备推送
	AudienceTypeToken AudienceType = "token"
	// AudienceTypeTokenList  设备列表推送
	AudienceTypeTokenList AudienceType = "token_list"
	// AudienceTypeAccount 单账号推送
	AudienceTypeAccount AudienceType = "account"
	// AudienceTypeAccountList 账号列表推送
	AudienceTypeAccountList AudienceType = "account_list"
)

type Authorization

type Authorization struct {
	AppID     string
	SecretKey string
}

Authorization 用来添加请求Authorization

type CommonRsp

type CommonRsp struct {
	// TODO: doc this
	Seq int64 `json:"seq"`
	// 推送id
	PushID string `json:"push_id"`
	// 错误码
	RetCode int `json:"ret_code"`
	// 用户指定推送环境,仅支持iOS
	Environment CommonRspEnv `json:"environment"`
	// 结果描述
	ErrMsg string `json:"err_msg,omitempty"`
	// 请求正确且有额外数据时,则结果在这个字段中
	Result map[string]string `json:"result,omitempty"`
}

CommonRsp 信鸽推送接口的通用基础返回值

type CommonRspEnv

type CommonRspEnv string

CommonRspEnv 信鸽推送接口通用基础返回值的environment字段

const (
	// EnvProd 生产环境
	EnvProd CommonRspEnv = "product"
	// EnvDev 测试环境
	EnvDev CommonRspEnv = "dev"
)

type IAuth

type IAuth interface {
	// contains filtered or unexported methods
}

IAuth 授权工具接口

func MakeAuthoraztion

func MakeAuthoraztion(appId string, secretKey string) IAuth

MakeAuthoraztion 构造一个鉴权

type IOSParams

type IOSParams struct {
	Aps    *Aps              `json:"aps,omitempty"`
	Custom map[string]string `json:"custom,omitempty"`
}

IOSParams iOS push参数

func DefaultIOSParams

func DefaultIOSParams(title string, content string) *IOSParams

DefaultIOSParams 默认的iOS推送参数

type IPushMsg

type IPushMsg interface {
	RenderOptions(opts ...PushMsgOption) error
	// contains filtered or unexported methods
}

IPushMsg PushMsg实现的接口

func DefaultPushMsg

func DefaultPushMsg(platform Platform, msgType MessageType, title string, content string) IPushMsg

DefaultPushMsg 创建基础的推送消息

func NewAccountNotifyPushMsg

func NewAccountNotifyPushMsg(platform Platform, title string, content string, accounts ...string) IPushMsg

NewAccountNotifyPushMsg 基于account的notify类型的推送

func NewAccountPushMsg

func NewAccountPushMsg(platform Platform, msgType MessageType, title string, content string, accounts ...string) IPushMsg

NewAccountPushMsg 基于account的推送

func NewPushAllNotifyPushMsg

func NewPushAllNotifyPushMsg(platform Platform, title string, content string) IPushMsg

NewPushAllNotifyPushMsg 基于notify类型的全员推送

func NewPushAllPushMsg

func NewPushAllPushMsg(platform Platform, msgType MessageType, title string, content string) IPushMsg

NewPushAllPushMsg 全员推送

func NewTagNotifyPushMsg

func NewTagNotifyPushMsg(platform Platform, title string, content string, tagOpt TagOperation, tags ...string) IPushMsg

NewTagNotifyPushMsg 基于tag的notify类型的推送

func NewTagPushMsg

func NewTagPushMsg(platform Platform, msgType MessageType, title string, content string, tagOpt TagOperation, tags ...string) IPushMsg

NewTagPushMsg tag类型的推送

func NewTokenNotifyPushMsg

func NewTokenNotifyPushMsg(platform Platform, title string, content string, tokens ...string) IPushMsg

NewTokenNotifyPushMsg 基于token的notify类型的推送

func NewTokenPushMsg

func NewTokenPushMsg(platform Platform, msgType MessageType, title string, content string, tokens ...string) IPushMsg

NewTokenPushMsg 新建token类型的

type Message

type Message struct {
	Title      string   `json:"title,omitempty"`
	Content    string   `json:"content,omitempty"`
	AcceptTime []string `json:"accept_time,omitempty"`
	//Android推送的参数
	Android *AndroidParams `json:"android,omitempty"`
	//IOS推送的参数
	IOS *IOSParams `json:"ios,omitempty"`
}

Message 消息体

type MessageType

type MessageType string

MessageType push API message_type参数

const (
	// MessageTypeOfNotify 消息类型为通知栏消息
	MessageTypeOfNotify MessageType = "notify"
	// MessageTypeOfMsg 消息类型为透传消息(android)/静默消息(iOS)
	MessageTypeOfMsg MessageType = "message"
)

type Platform

type Platform string

Platform push API platform参数

const (
	//PlatformAndroid Android推送平台标识
	PlatformAndroid Platform = "android"
	// PlatformiOS 苹果推送平台标识
	PlatformiOS Platform = "ios"
)

type PushMsg

type PushMsg struct {
	//AudienceType 受众类型,见AudienceType类型
	AudienceType `json:"audience_type"`
	//Platform 推送平台,见Platform类型
	Platform `json:"platform"`
	//Message 消息内容
	Message `json:"message"`
	//MessageType 消息类型,见MessageType类型
	MessageType `json:"message_type"`

	//TagList 当AudienceType == AdTag时必填
	TagList *TagList `json:"tag_list,omitempty"`
	/*TokenList 当AudienceType == AdToken 或 AdTokenList 时必填的参数,
	 当AdToken时即使传了多个token,也只有第一个会被推送
	 当AdTokenList时,最多支持1000个token,同时push_id第一次请求时必须填0
	 系统会返回一个push_id = 123(例),后续推送如果push_id填写123(例)
	则会使用跟123相同的文案推送*/
	TokenList []string `json:"token_list,omitempty"`
	//AccountList 当AudienceType == AudienceTypeAccount 或 AdAccountList 时必填的参数,
	// 当AdAccount时即使传了多个token,也只有第一个会被推送
	// 当AdAccountList时,最多支持1000个token,同时push_id第一次请求时必须填0
	// 系统会返回一个push_id = 123(例),后续推送如果push_id填写123(例)
	//AccountList 则会使用跟123相同的文案推送
	AccountList []string `json:"account_list,omitempty"`

	//ExpireTime 	消息离线存储时间(单位为秒)
	// 最长存储时间3天,若设置为0,则默认值(3天)
	// 建议取值区间[600, 86400x3]
	//ExpireTime 第三方通道离线保存消息不同厂商标准不同
	ExpireTime int `json:"expire_time,omitempty"`

	//SendTime 	指定推送时间
	// 格式为yyyy-MM-DD HH:MM:SS
	// 若小于服务器当前时间,则会立即推送
	//SendTime 仅全量推送和标签推送支持此字段
	SendTime string `json:"send_time,omitempty"`

	//MultiPkg 	多包名推送
	//MultiPkg 当app存在多个不同渠道包(例如应用宝、豌豆荚等),推送时如果是希望手机上安装任何一个渠道的app都能收到消息那么该值需要设置为true
	MultiPkg bool `json:"multi_pkg,omitempty"`

	//LoopTimes 	循环任务重复次数
	// 仅支持全推、标签推
	//LoopTimes 建议取值[1, 15]
	LoopTimes int `json:"loop_times,omitempty"`

	//Environment 	用户指定推送环境,仅限iOS平台推送使用
	// product: 推送生产环境
	//Environment dev: 推送开发环境
	Environment CommonRspEnv `json:"environment,omitempty"`

	//StatTag 	统计标签,用于聚合统计
	// 使用场景(示例):
	// 现在有一个活动id:active_picture_123,需要给10000个设备通过单推接口(或者列表推送等推送形式)下发消息,同时设置该字段为active_picture_123
	//StatTag 推送完成之后可以使用v3统计查询接口,根据该标签active_picture_123 查询这10000个设备的实发、抵达、展示、点击数据
	StatTag string `json:"stat_tag,omitempty"`

	//Seq 	接口调用时,在应答包中信鸽会回射该字段,可用于异步请求
	//Seq 使用场景:异步服务中可以通过该字段找到server端返回的对应应答包
	Seq int64 `json:"seq,omitempty"`

	//AccountType 单账号推送时可选
	// 	 账号类型,参考后面账号说明。
	//AccountType  必须与账号绑定时设定的账号类型一致
	AccountType int `json:"account_type,omitempty"`

	//PushID
	// 账号列表推送、设备列表推送时必需
	// 账号列表推送和设备列表推送时,第一次推送该值填0,系统会创建对应的推送任务,
	// 并且返回对应的pushid:123,后续推送push_id 填123(同一个文案)
	// 表示使用与123 id 对应的文案进行推送。(注:文案的有效时间由前面的expire_time 字段决定)
	PushID string `json:"push_id,omitempty"`
	// contains filtered or unexported fields
}

PushMsg 推送的消息体

func (*PushMsg) RenderOptions

func (rst *PushMsg) RenderOptions(opts ...PushMsgOption) error

RenderOptions 使用Option来动态修改PushMsg的内容

type PushMsgOption

type PushMsgOption func(*PushMsg) error

PushMsgOption Option函数的原型

func OptionAccountList

func OptionAccountList(al ...string) PushMsgOption

OptionAccountList 的注释

func OptionAccountListAdd

func OptionAccountListAdd(a string) PushMsgOption

OptionAccountListAdd 的注释

func OptionAccountType

func OptionAccountType(at int) PushMsgOption

OptionAccountType 的注释

func OptionAddAction

func OptionAddAction(k string, v interface{}) PushMsgOption

OptionAddAction 的注释

func OptionAndroidIntent added in v1.0.2

func OptionAndroidIntent(scheme string) PushMsgOption

OptionAndroidIntent 在Msg中放置intent

func OptionAndroidParams

func OptionAndroidParams(params *AndroidParams) PushMsgOption

OptionAndroidParams 设置AndroidParams

func OptionAps

func OptionAps(aps *Aps) PushMsgOption

OptionAps 的注释

func OptionApsAlert

func OptionApsAlert(alert Alert) PushMsgOption

OptionApsAlert 设置Alert

func OptionApsBadage

func OptionApsBadage(badge int) PushMsgOption

OptionApsBadage 设置Badage

func OptionApsCategory

func OptionApsCategory(category string) PushMsgOption

OptionApsCategory 设置属性

func OptionApsContentAvailable

func OptionApsContentAvailable(contentAvailable int) PushMsgOption

OptionApsContentAvailable 设置属性

func OptionApsSound

func OptionApsSound(sound string) PushMsgOption

OptionApsSound 设置属性

func OptionApsThreadId

func OptionApsThreadId(threadId string) PushMsgOption

OptionApsThreadId 设置属性

func OptionBuilderID

func OptionBuilderID(id int) PushMsgOption

OptionBuilderID 的注释

func OptionCleanable

func OptionCleanable(c int) PushMsgOption

OptionCleanable 的注释

func OptionContent

func OptionContent(c string) PushMsgOption

OptionContent 的注释

func OptionCustomContent

func OptionCustomContent(ct map[string]string) PushMsgOption

OptionCustomContent 的注释

func OptionCustomContentSet

func OptionCustomContentSet(k, v string) PushMsgOption

OptionCustomContentSet 的注释

func OptionEnvDevelop

func OptionEnvDevelop() PushMsgOption

OptionEnvDevelop 的注释

func OptionEnvProduction

func OptionEnvProduction() PushMsgOption

OptionEnvProduction 的注释

func OptionExpireTime

func OptionExpireTime(et time.Time) PushMsgOption

OptionExpireTime 的注释

func OptionIOSParams

func OptionIOSParams(params *IOSParams) PushMsgOption

OptionIOSParams 设置IOSParams

func OptionIconRes

func OptionIconRes(ir string) PushMsgOption

OptionIconRes 的注释

func OptionIconType

func OptionIconType(it int) PushMsgOption

OptionIconType 的注释

func OptionLights

func OptionLights(l int) PushMsgOption

OptionLights 的注释

func OptionLoopTimes

func OptionLoopTimes(lt int) PushMsgOption

OptionLoopTimes 的注释

func OptionMessage

func OptionMessage(m Message) PushMsgOption

OptionMessage 的注释

func OptionMessageType

func OptionMessageType(t MessageType) PushMsgOption

OptionMessageType 的注释

func OptionMultiPkg

func OptionMultiPkg(mp bool) PushMsgOption

OptionMultiPkg 的注释

func OptionNID

func OptionNID(id int) PushMsgOption

OptionNID 的注释

func OptionPlatAndroid

func OptionPlatAndroid() PushMsgOption

OptionPlatAndroid 的注释

func OptionPlatIos

func OptionPlatIos() PushMsgOption

OptionPlatIos 的注释

func OptionPlatform

func OptionPlatform(p Platform) PushMsgOption

OptionPlatform 的注释

func OptionPushID

func OptionPushID(pid string) PushMsgOption

OptionPushID 的注释

func OptionRing

func OptionRing(ring int) PushMsgOption

OptionRing 的注释

func OptionRingRaw

func OptionRingRaw(rr string) PushMsgOption

OptionRingRaw 的注释

func OptionSendTime

func OptionSendTime(st time.Time) PushMsgOption

OptionSendTime 修改发送时间

func OptionSeq

func OptionSeq(s int64) PushMsgOption

OptionSeq 的注释

func OptionSmallIcon

func OptionSmallIcon(si int) PushMsgOption

OptionSmallIcon 的注释

func OptionStatTag

func OptionStatTag(st string) PushMsgOption

OptionStatTag 的注释

func OptionStyleID

func OptionStyleID(s int) PushMsgOption

OptionStyleID 的注释

func OptionTagList

func OptionTagList(op TagOperation, tags ...string) PushMsgOption

OptionTagList 的注释

func OptionTagListOpt2

func OptionTagListOpt2(tl TagList) PushMsgOption

OptionTagListOpt2 的注释

func OptionTitle

func OptionTitle(t string) PushMsgOption

OptionTitle 的注释

func OptionTokenList

func OptionTokenList(tl ...string) PushMsgOption

OptionTokenList 的注释

func OptionTokenListAdd

func OptionTokenListAdd(t string) PushMsgOption

OptionTokenListAdd 的注释

func OptionVibrate

func OptionVibrate(v int) PushMsgOption

OptionVibrate 的注释

type TagList

type TagList struct {
	//Tags 标签
	Tags []string `json:"tags"`
	//TagOperation 标签逻辑操作符
	TagOperation `json:"op"`
}

TagList 标签推送参数

type TagOperation

type TagOperation string

TagOperation 标签推送参数的逻辑操作符

const (
	// TagOperationAnd 推送tag1且tag2
	TagOperationAnd TagOperation = "AND"
	// TagOperationOr 推送tag1或tag2
	TagOperationOr TagOperation = "OR"
)

type XgClient

type XgClient struct {
	// contains filtered or unexported fields
}

XgClient 用来推送消息,或者设置Tag的信鸽客户端

func NewXingeClient

func NewXingeClient(androidAuth IAuth, iOSAuth IAuth, client *http.Client) XgClient

NewXingeClient 构建一个完整的XgClient对象

func NewXingeClient3

func NewXingeClient3() XgClient

NewXingeClient3 无参数构建一个XgClient对象

func NewXingeClientent2

func NewXingeClientent2(appId string, secretKey string, platform Platform) XgClient

NewXingeClientent2 构建一个单平台的XgClient对象

func (XgClient) MarshalResp

func (xg XgClient) MarshalResp(resp *http.Response) CommonRsp

MarshalResp 解析返回

func (XgClient) Push

func (xg XgClient) Push(msg IPushMsg) CommonRsp

Push 推送消息

func (XgClient) PushWithAuthorization

func (xg XgClient) PushWithAuthorization(msg IPushMsg, auth IAuth) CommonRsp

PushWithAuthorization 使用自定义的Authorization信息进行推送

func (*XgClient) SetAndroidAuth

func (xg *XgClient) SetAndroidAuth(auth IAuth)

SetAndroidAuth 设置默认的Android平台推送鉴权

func (*XgClient) SetAuth

func (xg *XgClient) SetAuth(appId string, secretKey string, platform Platform)

SetAuth 设置某个平台的鉴权信息

func (*XgClient) SetIOSAuth

func (xg *XgClient) SetIOSAuth(auth IAuth)

SetIOSAuth 设置默认的iOS平台推送鉴权

Jump to

Keyboard shortcuts

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