gomipush

package module
v0.0.0-...-858b6ca Latest Latest
Warning

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

Go to latest
Published: May 23, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

README

gomipush

Usage

android client
First create client and message:
title := "gomipush sdk send to alias123"
description := "gomipush sdk send to alias123"
passThrough := 0
client := NewClient("security")
msg := NewAndroidMessage(title, description , passThrough , []string{restrictedPackageName})
Sencod do send
  • Send to topic:
  topic := "abc"
  rsp, err := client.Send(msg).ToTopic(topic).Do(context.Background())
  • Send to multi topics
  topic := []string{"abc","abc2"}
  rsp, err := client.Send(msg).ToMultiTopic(topic, op).Do(context.Background())
  //op is type BroadcastTopicOp ,and can must be one in [Union, Intersection, Except]
  • Send to RegId
  regId := []string{"abc"}
  rsp, err := client.Send(msg).ToToRegID(regId).Do(context.Background())
  • Send to Alias
  alias := []string{"abc"}
  rsp, err := client.Send(msg).ToAlias(alias).Do(context.Background())
  • Send to userAccount
userAccount := []string{"abc"}
rsp, err := client.Send(msg).ToUserAccount(userAccount).Do(context.Background())
  • Send to All
rsp, err := client.Send(msg).ToAll().Do(context.Background())
ios client

Important

大部分用例未经测试

Documentation

Index

Constants

View Source
const (
	BROADCAST_TOPIC_MAX = 5
)
View Source
const MAX_BACKOFF_DELAY = 1024000
View Source
const (
	VERSION = "1.0.0"
)

Variables

View Source
var (
	METHOD_MAP = map[HttpMethod]string{
		HTTP_GET:  "GET",
		HTTP_POST: "POST",
	}

	V2_SEND          = []string{"/v2/send"}
	V2_REGID_MESSAGE = []string{"/v2/message/regid"}
	V3_REGID_MESSAGE = []string{"/v3/message/regid"}

	V2_SUBSCRIBE_TOPIC            = []string{"/v2/topic/subscribe"}
	V2_UNSUBSCRIBE_TOPIC          = []string{"/v2/topic/unsubscribe"}
	V2_SUBSCRIBE_TOPIC_BY_ALIAS   = []string{"/v2/topic/subscribe/alias"}
	V2_UNSUBSCRIBE_TOPIC_BY_ALIAS = []string{"/v2/topic/unsubscribe/alias"}

	V2_ALIAS_MESSAGE = []string{"/v2/message/alias"}
	V3_ALIAS_MESSAGE = []string{"/v3/message/alias"}

	V2_BROADCAST_TO_ALL         = []string{"/v2/message/all"}
	V3_BROADCAST_TO_ALL         = []string{"/v3/message/all"}
	V2_BROADCAST                = []string{"/v2/message/topic"}
	V3_BROADCAST                = []string{"/v3/message/topic"}
	V2_MULTI_TOPIC_BROADCAST    = []string{"/v2/message/multi_topic"}
	V3_MILTI_TOPIC_BROADCAST    = []string{"/v3/message/multi_topic"}
	V2_DELETE_BROADCAST_MESSAGE = []string{"/v2/message/delete"}

	V2_USER_ACCOUNT_MESSAGE = []string{"/v2/message/user_account"}

	V2_SEND_MULTI_MESSAGE_WITH_REGID   = []string{"/v2/multi_messages/regids"}
	V2_SEND_MULTI_MESSAGE_WITH_ALIAS   = []string{"/v2/multi_messages/aliases"}
	V2_SEND_MULTI_MESSAGE_WITH_ACCOUNT = []string{"/v2/multi_messages/user_accounts"}

	V1_VALIDATE_REGID  = []string{"/v1/validation/regids"}
	V1_GET_ALL_ACCOUNT = []string{"/v1/account/all"}
	V1_GET_ALL_TOPIC   = []string{"/v1/topic/all"}
	V1_GET_ALL_ALIAS   = []string{"/v1/alias/all"}

	V1_MESSAGES_STATUS      = []string{"/v1/trace/messages/status"}
	V1_MESSAGE_STATUS       = []string{"/v1/trace/message/status"}
	V1_GET_MESSAGE_COUNTERS = []string{"/v1/stats/message/counters"}

	V1_FEEDBACK_INVALID_ALIAS = []interface{}{"/v1/feedback/fetch_invalid_aliases", Feedback}
	V1_FEEDBACK_INVALID_REGID = []interface{}{"/v1/feedback/fetch_invalid_regids", Feedback}

	V1_REGID_PRESENCE = []string{"/v1/regid/presence"}
	V2_REGID_PRESENCE = []string{"/v1/regid/presence"}

	V2_DELETE_SCHEDULE_JOB      = []string{"/v2/schedule_job/delete"}
	V3_DELETE_SCHEDULE_JOB      = []string{"/v3/schedule_job/delete"}
	V2_CHECK_SCHEDULE_JOB_EXIST = []string{"/v2/schedule_job/exist"}
	V2_QUERY_SCHEDULE_JOB       = []string{"/v2/schedule_job/query"}

	V1_EMQ_ACK_INFO      = []string{"/msg/ack/info", string(Emq)}
	V1_EMQ_CLICK_INFO    = []string{"/msg/click/info", string(Emq)}
	V1_EMQ_INVALID_REGID = []string{"/app/invalid/regid", string(Emq)}
)

Functions

This section is empty.

Types

type AndroidExtra

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

type AndroidMessage

type AndroidMessage struct {
	BaseMessage
	// contains filtered or unexported fields
}

func NewAndroidMessage

func NewAndroidMessage(title, description string) *AndroidMessage

func NewAndroidMessagePassThrough

func NewAndroidMessagePassThrough(payload string) *AndroidMessage

func (*AndroidMessage) Description

func (ad *AndroidMessage) Description(description string) *AndroidMessage

func (*AndroidMessage) ExtraAppVersion

func (ad *AndroidMessage) ExtraAppVersion(appVersion []string) *AndroidMessage

func (*AndroidMessage) ExtraAppVersionNotIn

func (ad *AndroidMessage) ExtraAppVersionNotIn(appVersionNotIn []string) *AndroidMessage

func (*AndroidMessage) ExtraCallback

func (ad *AndroidMessage) ExtraCallback(callback string) *AndroidMessage

func (*AndroidMessage) ExtraConnpt

func (ad *AndroidMessage) ExtraConnpt(connpt string) *AndroidMessage

func (*AndroidMessage) ExtraFlowControl

func (ad *AndroidMessage) ExtraFlowControl(flowControl int) *AndroidMessage

func (*AndroidMessage) ExtraIntentUri

func (ad *AndroidMessage) ExtraIntentUri(intentUri string) *AndroidMessage

func (*AndroidMessage) ExtraJobkey

func (ad *AndroidMessage) ExtraJobkey(jobkey string) *AndroidMessage

func (*AndroidMessage) ExtraLayoutName

func (ad *AndroidMessage) ExtraLayoutName(layoutName string) *AndroidMessage

func (*AndroidMessage) ExtraLayoutValue

func (ad *AndroidMessage) ExtraLayoutValue(layoutValue string) *AndroidMessage

func (*AndroidMessage) ExtraLocale

func (ad *AndroidMessage) ExtraLocale(locale []string) *AndroidMessage

func (*AndroidMessage) ExtraLocaleNotIn

func (ad *AndroidMessage) ExtraLocaleNotIn(localeNotIn []string) *AndroidMessage

func (*AndroidMessage) ExtraModel

func (ad *AndroidMessage) ExtraModel(model []string) *AndroidMessage

func (*AndroidMessage) ExtraModelNotIn

func (ad *AndroidMessage) ExtraModelNotIn(modelNotIn []string) *AndroidMessage

func (*AndroidMessage) ExtraNotifyEffect

func (ad *AndroidMessage) ExtraNotifyEffect(notifyEffect int) *AndroidMessage

func (*AndroidMessage) ExtraNotifyForeground

func (ad *AndroidMessage) ExtraNotifyForeground(notifyForeground int) *AndroidMessage

func (*AndroidMessage) ExtraWebUri

func (ad *AndroidMessage) ExtraWebUri(webUri string) *AndroidMessage

func (*AndroidMessage) Extraticker

func (ad *AndroidMessage) Extraticker(ticker string) *AndroidMessage

func (*AndroidMessage) NotifyId

func (ad *AndroidMessage) NotifyId(notifyId int) *AndroidMessage

func (*AndroidMessage) NotifyType

func (ad *AndroidMessage) NotifyType(notifyType NotifyType) *AndroidMessage

func (*AndroidMessage) PassThrough

func (ad *AndroidMessage) PassThrough(passThrough int) *AndroidMessage

func (*AndroidMessage) Payload

func (ad *AndroidMessage) Payload(payload string) *AndroidMessage

func (*AndroidMessage) RestrictedPackageName

func (ad *AndroidMessage) RestrictedPackageName(packages []string) *AndroidMessage

func (*AndroidMessage) Source

func (ad *AndroidMessage) Source() (interface{}, error)

func (*AndroidMessage) TimeToLive

func (ad *AndroidMessage) TimeToLive(timeToLive int64) *AndroidMessage

func (*AndroidMessage) TimeToSend

func (ad *AndroidMessage) TimeToSend(timeToSend int64) *AndroidMessage

func (*AndroidMessage) Title

func (ad *AndroidMessage) Title(title string) *AndroidMessage

type BaseMessage

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

func (*BaseMessage) Alias

func (base *BaseMessage) Alias(alias []string)

func (*BaseMessage) MulitTopic

func (base *BaseMessage) MulitTopic(topic []string, op BroadcastTopicOp)

func (*BaseMessage) RegId

func (base *BaseMessage) RegId(regId []string)

func (*BaseMessage) Source

func (base *BaseMessage) Source() (interface{}, error)

func (*BaseMessage) Topic

func (base *BaseMessage) Topic(topic string)

func (*BaseMessage) UserAccount

func (base *BaseMessage) UserAccount(userAcct []string)

type BroadcastTopicOp

type BroadcastTopicOp string
const (
	Union        BroadcastTopicOp = "UNION"
	Intersection BroadcastTopicOp = "INTERSECTION"
	Except       BroadcastTopicOp = "EXCEPT"
)

”'

Union 并集
Intersection 交集
Except 差集

”'

type Client

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

func NewClient

func NewClient(security string) *Client

func (*Client) PerformRequest

func (c *Client) PerformRequest(ctx context.Context, requestPath []string, retryTimes int, method HttpMethod, params url.Values, body string) (*Response, error)

func (*Client) Proxy

func (c *Client) Proxy(proxyIp string, proxyPort string) (*Client, error)

func (*Client) Send

func (c *Client) Send(msg Message) (*SenderService, error)

func (*Client) Subscribe

func (c *Client) Subscribe(topic SubscribedTopic) *SubscribeService

func (*Client) Token

func (c *Client) Token(token string) *Client

func (*Client) Tool

func (c *Client) Tool() *Tool

type Error

type Error struct {
	AppStatus int    `json:"-"`
	AppReason string `json:"-"`

	Result      string `json:"result,omitempty"`
	Reason      string `json:"reason,omitempty"`
	TraceId     string `json:"trace_id,omitempty"`
	Code        int    `json:"code,omitempty"`
	Description string `json:"description,omitempty"`
	ErrorCode   int    `json:"errorCode,omitempty"`
}

func (*Error) Error

func (e *Error) Error() string

type HttpMethod

type HttpMethod int
const (
	HTTP_GET HttpMethod = iota
	HTTP_POST
)

type IOSApsProperField

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

type IOSExtra

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

type IOSMessage

type IOSMessage struct {
	BaseMessage
	// contains filtered or unexported fields
}

func NewIOSMessage

func NewIOSMessage(description string) *IOSMessage

func (*IOSMessage) ApsBody

func (ios *IOSMessage) ApsBody(body string) *IOSMessage

func (*IOSMessage) ApsMutableContent

func (ios *IOSMessage) ApsMutableContent(mutableContent string) *IOSMessage

func (*IOSMessage) ApsSubtitle

func (ios *IOSMessage) ApsSubtitle(subtitle string) *IOSMessage

func (*IOSMessage) ApsTitle

func (ios *IOSMessage) ApsTitle(title string) *IOSMessage

func (*IOSMessage) Description

func (ios *IOSMessage) Description(description string) *IOSMessage

func (*IOSMessage) ExtraBadge

func (ios *IOSMessage) ExtraBadge(badge int) *IOSMessage

func (*IOSMessage) ExtraCategory

func (ios *IOSMessage) ExtraCategory(category string) *IOSMessage

func (*IOSMessage) ExtraSoundUrl

func (ios *IOSMessage) ExtraSoundUrl(soundUrl string) *IOSMessage

func (*IOSMessage) Source

func (ad *IOSMessage) Source() (interface{}, error)

func (*IOSMessage) TimeToLive

func (ios *IOSMessage) TimeToLive(timeToLive int64) *IOSMessage

func (*IOSMessage) TimeToSend

func (ios *IOSMessage) TimeToSend(timeToSend int64) *IOSMessage

type Message

type Message interface {
	Source() (interface{}, error)
	RegId(regId []string)                           //发送给一组设备,不同的registration_id之间用“,”分割
	Alias(alias []string)                           //可以提供多个alias,发送给一组设备,不同的alias之间用“,”分割。
	UserAccount(userAcct []string)                  //发送消息给设置了该user_account的所有设备。可以提供多个user_account,user_account之间用“,”分割。
	Topic(topic string)                             //发送消息给订阅了该topic的所有设备。
	MulitTopic(topic []string, op BroadcastTopicOp) //Stringtopicstopic列表,使用;$;分割。注: topics参数需要和topic_op参数配合使用,另外topic的数量不能超过5。UNION并集 INTERSECTION交集 EXCEPT差集
	// contains filtered or unexported methods
}

type NotifyType

type NotifyType int
const (
	DEFAULT_ALL     NotifyType = -1
	DEFAULT_SOUND   NotifyType = 1 << iota / 2 // 使用默认提示音提示
	DEFAULT_VIBRATE                            // 使用默认震动提示
	DEFAULT_LIGHTS                             // 使用默认led灯光提示
)

type RequestType

type RequestType string
const (
	Msg      RequestType = "1"
	Feedback RequestType = "2"
	Emq      RequestType = "3"
)

type Response

type Response struct {
	AppStatus int    `json:"-"`
	AppReason string `json:"-"`

	Result      string                 `json:"result,omitempty"`
	TraceID     string                 `json:"trace_id,omitempty"`
	Code        int                    `json:"code,omitempty"`
	Data        map[string]interface{} `json:"data,omitempty"`
	Description string                 `json:"description,omitempty"`
	Info        string                 `json:"info,omitempty"`
}

type SenderService

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

func NewSenderService

func NewSenderService(c *Client, msg Message) (*SenderService, error)

func (*SenderService) Do

func (ss *SenderService) Do(ctx context.Context) (*Response, error)

func (*SenderService) RetryTimes

func (ss *SenderService) RetryTimes(retryTimes int) *SenderService
func (ss *SenderService) Message(msg Message) *SenderService{
    ss.message = msg
    return ss
}

func (*SenderService) ToAlias

func (ss *SenderService) ToAlias(alias []string) *SenderService

func (*SenderService) ToAll

func (ss *SenderService) ToAll() *SenderService

func (*SenderService) ToMultiTopic

func (ss *SenderService) ToMultiTopic(topic []string, topicOp BroadcastTopicOp) (*SenderService, error)

func (*SenderService) ToRegID

func (ss *SenderService) ToRegID(regId []string) *SenderService

func (*SenderService) ToTopic

func (ss *SenderService) ToTopic(topic string) *SenderService

func (*SenderService) ToUserAccount

func (ss *SenderService) ToUserAccount(userAccount []string) *SenderService

type SenderTarget

type SenderTarget int

type Server

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

func NewServer

func NewServer(host string, minPriority int, maxPriority int, decrStep int, incrStep int) *Server

func (*Server) DecrPriority

func (s *Server) DecrPriority()

func (*Server) GetHost

func (s *Server) GetHost() string

func (*Server) IncrPriority

func (s *Server) IncrPriority()

type ServerSwitch

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

func NewServerSwitch

func NewServerSwitch() *ServerSwitch

func (*ServerSwitch) Initialize

func (ss *ServerSwitch) Initialize(hostList string)

func (*ServerSwitch) NeedRefreshHostList

func (ss *ServerSwitch) NeedRefreshHostList() bool

func (*ServerSwitch) SelectServer

func (ss *ServerSwitch) SelectServer(requestPath []string) *Server

type SubscribeService

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

func NewSubscribeService

func NewSubscribeService(c *Client, topic SubscribedTopic) *SubscribeService

func (*SubscribeService) Do

func (ss *SubscribeService) Do(ctx context.Context) (*Response, error)

func (*SubscribeService) SubscribeAlias

func (ss *SubscribeService) SubscribeAlias(alias []string) *SubscribeService

func (*SubscribeService) SubscribeRegIds

func (ss *SubscribeService) SubscribeRegIds(regId []string) *SubscribeService

func (*SubscribeService) UnsubscribeAlias

func (ss *SubscribeService) UnsubscribeAlias(alias []string) *SubscribeService

func (*SubscribeService) UnsubscribeRegIds

func (ss *SubscribeService) UnsubscribeRegIds(regId []string) *SubscribeService

type SubscribeType

type SubscribeType int
const (
	RegId SubscribeType = iota + 1
	Alias
)

type SubscribedTopic

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

func NewSubscribedTopic

func NewSubscribedTopic(topic string) *SubscribedTopic

func (*SubscribedTopic) Alias

func (st *SubscribedTopic) Alias(alias []string)

func (*SubscribedTopic) Category

func (st *SubscribedTopic) Category(category string) *SubscribedTopic

func (*SubscribedTopic) RegId

func (st *SubscribedTopic) RegId(regId []string)

func (*SubscribedTopic) RestrictedPackageName

func (st *SubscribedTopic) RestrictedPackageName(packageName []string) *SubscribedTopic

func (*SubscribedTopic) Source

func (st *SubscribedTopic) Source() interface{}

type TargetType

type TargetType int
const (
	TARGET_TYPE_REGID TargetType = iota + 1
	TARGET_TYPE_ALIAS
	TARGET_TYPE_USER_ACCOUNT
	TARGET_TYPE_TOPIC
	TARGET_TYPE_PACKAGE
)

type Tool

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

gomipush.NewClient("security").Tool().FetchClickInfo("package").DoGet(ctx)

func NewTool

func NewTool(c *Client) *Tool

func (*Tool) CheckScheduleJobExist

func (t *Tool) CheckScheduleJobExist(jobId string) *Tool

post test

func (*Tool) DeleteScheduleJob

func (t *Tool) DeleteScheduleJob(jobId string) *Tool

post test

func (*Tool) DeleteScheduleJobKey

func (t *Tool) DeleteScheduleJobKey(jobKey string) *Tool

!!post no test

func (*Tool) DeleteTopic

func (t *Tool) DeleteTopic(msgId string) *Tool

!!post request successfully but not work

func (*Tool) Do

func (t *Tool) Do(ctx context.Context) (*Response, error)

func (*Tool) FetchAckInfo

func (t *Tool) FetchAckInfo(packageName string) *Tool

func (*Tool) FetchClickInfo

func (t *Tool) FetchClickInfo(packageName string) *Tool

func (*Tool) FetchInvalidRegId

func (t *Tool) FetchInvalidRegId(packageName string) *Tool

func (*Tool) QueryDeviceAliases

func (t *Tool) QueryDeviceAliases(packageName, regId string) *Tool

get

func (*Tool) QueryDevicePresence

func (t *Tool) QueryDevicePresence(packageName string, regId []string) *Tool

get

func (*Tool) QueryDeviceUserAccounts

func (t *Tool) QueryDeviceUserAccounts(packageName, regId string) *Tool

get

func (*Tool) QueryInvalidRegIds

func (t *Tool) QueryInvalidRegIds() *Tool

get

func (*Tool) QueryMessageGroupStatus

func (t *Tool) QueryMessageGroupStatus(jobKey string) *Tool

func (*Tool) QueryMessageStatus

func (t *Tool) QueryMessageStatus(msgId string) *Tool

func (*Tool) QueryMessageStatusTimeRange

func (t *Tool) QueryMessageStatusTimeRange(beginTime int64, endTime int64) *Tool

func (*Tool) QueryStatData

func (t *Tool) QueryStatData(beginTime int64, endTime int64, packageName string) *Tool

func (*Tool) RequestMethod

func (t *Tool) RequestMethod(m HttpMethod) *Tool

func (*Tool) RetryTimes

func (t *Tool) RetryTimes(retryTimes int) *Tool

func (*Tool) ValidateRegIds

func (t *Tool) ValidateRegIds(regId []string) *Tool

Jump to

Keyboard shortcuts

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