Help us shape the future of Go! Take the 2026 Go Developer Survey

jpush

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2019 License: MIT Imports: 11 Imported by: 0

README

JPush GO SDK

极光推送golang sdk。 官方的go sdk就新建了项目,没有文件,故开发本SDK。   使用教程直接参照单元测试代码即可。

功能列表

  • Push API v3
  • Report API v3
  • Device API v3
  • Schedule API v3

单元测试

  1. 添加APP_KEY和MASTER_SECRET以及REGISTRATION_ID到环境变量
  2. go test

如何使用

参照单元测试即可

注意

VIP类接口和Admin API v1由于暂时没有权限,没有做实现。有需要的可以提交PR。

Documentation

Index

Constants

View Source
const (
	ScheduleTimeUnitDay   = "day"
	ScheduleTimeUnitWeek  = "week"
	ScheduleTimeUnitMonth = "month"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AppKey       string
	MasterSecret string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(appKey, masterSecret string) *Client

func (*Client) DeviceBindTags

func (c *Client) DeviceBindTags(tag string, req *DeviceBindTagsRequest) ([]byte, error)

func (*Client) DeviceCheckDeviceWithTag

func (c *Client) DeviceCheckDeviceWithTag(tag, registrationId string) (map[string]interface{}, error)

func (*Client) DeviceDeleteAlias

func (c *Client) DeviceDeleteAlias(alias string) ([]byte, error)

func (*Client) DeviceDeleteTag

func (c *Client) DeviceDeleteTag(tag string, platforms []string) ([]byte, error)

func (*Client) DeviceEmptyTagsRequest

func (c *Client) DeviceEmptyTagsRequest(registrationId string, req *DeviceSettingEmptyTagsRequest) ([]byte, error)

func (*Client) DeviceGetTags

func (c *Client) DeviceGetTags() (map[string]interface{}, error)

func (*Client) DeviceGetWithAlias

func (c *Client) DeviceGetWithAlias(alias string, platforms []string) (map[string]interface{}, error)

func (*Client) DeviceRequest

func (c *Client) DeviceRequest(registrationId string, req *DeviceSettingRequest) ([]byte, error)

func (*Client) DeviceView

func (c *Client) DeviceView(registrationId string) (map[string]interface{}, error)

func (*Client) GetCidPool

func (c *Client) GetCidPool(count int, cidType string) (map[string]interface{}, error)

func (*Client) GroupPush

func (c *Client) GroupPush(push *PushRequest) (map[string]interface{}, error)

func (*Client) Push

func (c *Client) Push(push *PushRequest) (map[string]interface{}, error)

func (*Client) PushSingle

func (c *Client) PushSingle(push *PushSingleRequest) (map[string]interface{}, error)

func (*Client) ReportMessages

func (c *Client) ReportMessages(msgIds []string) ([]interface{}, error)

vip

func (*Client) ReportMessagesDetail

func (c *Client) ReportMessagesDetail(msgIds []string) ([]interface{}, error)

vip

func (*Client) ReportReceived

func (c *Client) ReportReceived(msgIds []string) ([]interface{}, error)

func (*Client) ReportReceivedDetail

func (c *Client) ReportReceivedDetail(msgIds []string) ([]interface{}, error)

vip

func (*Client) ReportStatusMessage

func (c *Client) ReportStatusMessage(req *ReportStatusRequest) (map[string]interface{}, error)

func (*Client) ScheduleCreateTask

func (c *Client) ScheduleCreateTask(req *ScheduleRequest) (map[string]interface{}, error)

func (*Client) ScheduleDelete

func (c *Client) ScheduleDelete(id string) ([]byte, error)

func (*Client) ScheduleGetList

func (c *Client) ScheduleGetList(page int) (map[string]interface{}, error)

func (*Client) ScheduleUpdate

func (c *Client) ScheduleUpdate(id string, req *ScheduleRequest) (map[string]interface{}, error)

func (*Client) ScheduleView

func (c *Client) ScheduleView(id string) (map[string]interface{}, error)

func (*Client) Validate

func (c *Client) Validate(req *PushRequest) (map[string]interface{}, error)

type DeviceBindTagsRequest

type DeviceBindTagsRequest struct {
	Add    []string `json:"add,omitempty"`
	Remove []string `json:"remove,omitempty"`
}

type DeviceSettingEmptyTagsRequest

type DeviceSettingEmptyTagsRequest struct {
	Tags   string `json:"tags"`
	Alias  string `json:"alias"`
	Mobile string `json:"mobile"`
}

type DeviceSettingRequest

type DeviceSettingRequest struct {
	Tags   *DeviceSettingRequestTags `json:"tags"`
	Alias  string                    `json:"alias"`
	Mobile string                    `json:"mobile"`
}

type DeviceSettingRequestTags

type DeviceSettingRequestTags struct {
	Add    []string `json:"add,omitempty"`
	Remove []string `json:"remove,omitempty"`
}

type NotificationAndroid

type NotificationAndroid struct {
	Alert       string                 `json:"alert"`
	Title       string                 `json:"title,omitempty"`
	BuilderId   int                    `json:"builder_id,int,omitempty"`
	Priority    int                    `json:"priority,omitempty"`
	Category    string                 `json:"category,omitempty"`
	Style       int                    `json:"style,int,omitempty"`
	AlertType   int                    `json:"alert_type,int,omitempty"`
	BigText     string                 `json:"big_text,omitempty"`
	Inbox       map[string]interface{} `json:"inbox,omitempty"`
	BigPicPath  string                 `json:"big_pic_path,omitempty"`
	Extras      map[string]interface{} `json:"extras,omitempty"`
	UriActivity string                 `json:"uri_activity,omitempty"` // 兼容华为
	UriAction   string                 `json:"uri_action,omitempty"`   //兼容小米
}

type NotificationIOS

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

type NotificationWinPhone

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

type Platform

type Platform string
const (
	PlatformAndroid  Platform = "android"
	PlatformIOS      Platform = "ios"
	PlatformWinPhone Platform = "winphone"
)

type PushAudience

type PushAudience struct {
	Tag            []string `json:"tag,omitempty"`
	TagAnd         []string `json:"tag_and,omitempty"`
	TagNot         []string `json:"tag_not,omitempty"`
	Alias          []string `json:"alias,omitempty"`
	RegistrationId []string `json:"registration_id,omitempty"`
	Segment        []string `json:"segment,omitempty"`
	ABTest         []string `json:"abtest,omitempty"`
}

type PushList

type PushList struct {
	Cid struct {
		Platform     Platform          `json:"platform"`
		Target       Target            `json:"target"`
		Notification *PushNotification `json:"notification,omitempty"`
		Message      *PushMessage      `json:"message,omitempty"`
		SmsMessage   *SmsMessage       `json:"sms_message,omitempty"`
		Options      *PushOptions      `json:"options,omitempty"`
	}
}

type PushMessage

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

type PushNotification

type PushNotification struct {
	Alert    string                `json:"alert,omitempty"`
	Android  *NotificationAndroid  `json:"android,omitempty"`
	IOS      *NotificationIOS      `json:"ios,omitempty"`
	WinPhone *NotificationWinPhone `json:"winphone,omitempty"`
}

type PushOptions

type PushOptions struct {
	SendNo          int    `json:"sendno,int,omitempty"`
	TimeToLive      int    `json:"time_to_live,int,omitempty"`
	OverrideMsgId   int64  `json:"override_msg_id,int64,omitempty"`
	ApnsProduction  bool   `json:"apns_production"`
	ApnsCollapseId  string `json:"apns_collapse_id,omitempty"`
	BigPushDuration int    `json:"big_push_duration,int,omitempty"`
}

type PushRequest

type PushRequest struct {
	Cid          string            `json:"cid,omitempty"`
	Platform     Platform          `json:"platform"`
	Audience     *PushAudience     `json:"audience,omitempty"`
	Notification *PushNotification `json:"notification,omitempty"`
	Message      *PushMessage      `json:"message,omitempty"`
	SmsMessage   *SmsMessage       `json:"sms_message,omitempty"`
	Options      *PushOptions      `json:"options,omitempty"`
}

type PushSingleRequest

type PushSingleRequest struct {
	PushList PushList
}

type ReportStatusRequest

type ReportStatusRequest struct {
	MsgId           int      `json:"msg_id,int"`
	RegistrationIds []string `json:"registration_ids"`
	Date            string   `json:"date,omitempty"`
}

type Response

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

func (*Response) Array

func (res *Response) Array() ([]interface{}, error)

func (*Response) Bytes

func (res *Response) Bytes() []byte

func (*Response) Map

func (res *Response) Map() (map[string]interface{}, error)

type ScheduleRequest

type ScheduleRequest struct {
	Cid     string           `json:"cid,omitempty"`
	Name    string           `json:"name"`
	Enabled bool             `json:"enabled"`
	Push    *PushRequest     `json:"push"`
	Trigger *ScheduleTrigger `json:"trigger"`
}

type ScheduleTrigger

type ScheduleTrigger struct {
	Single     *ScheduleTriggerSingle     `json:"single,omitempty"`
	Periodical *ScheduleTriggerPeriodical `json:"periodical,omitempty"`
}

type ScheduleTriggerPeriodical

type ScheduleTriggerPeriodical struct {
	Start     string      `json:"start,omitempty"`
	End       string      `json:"end,omitempty"`
	Time      string      `json:"time,omitempty"`
	TimeUnit  string      `json:"time_unit,omitempty"`
	Frequency int         `json:"frequency,int,omitempty"`
	Point     interface{} `json:"point,omitempty"`
}

type ScheduleTriggerSingle

type ScheduleTriggerSingle struct {
	Timer string `json:"time,omitempty"`
}

type SmsMessage

type SmsMessage struct {
	Content   string `json:"content"`
	DelayTime int    `json:"delay_time,int,omitempty"`
}

type Target

type Target string

Jump to

Keyboard shortcuts

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