jpush

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 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 AdminRequest added in v1.1.0

type AdminRequest struct {
	AppName        string `json:"app_name,string"`
	AndroidPackage string `json:"android_package,string"`
	GroupName      string `json:"group_name,string"`
}

type Client

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

func NewClient

func NewClient(appKey, masterSecret string) *Client

func (*Client) AdminCreateApp added in v1.1.0

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

func (*Client) AdminDeleteApp added in v1.1.0

func (c *Client) AdminDeleteApp(appKey string) ([]byte, error)

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) DeviceGetUserStatus added in v1.1.0

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

vip

func (*Client) DeviceGetWithAlias

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

func (*Client) DeviceRemoveBindAlias added in v1.1.0

func (c *Client) DeviceRemoveBindAlias(alias string, req *DeviceSettingRequestAlias) ([]byte, 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) FileDeleteTag added in v1.1.0

func (c *Client) FileDeleteTag(fileId string) ([]byte, error)

func (*Client) FileGetList added in v1.1.0

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

func (*Client) FileView added in v1.1.0

func (c *Client) FileView(fileId 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) ReportGetGroup added in v1.1.0

func (c *Client) ReportGetGroup(timeUnit, start, duration string) ([]interface{}, error)

func (*Client) ReportGetGroupMessages added in v1.1.0

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

func (*Client) ReportGetUsers added in v1.1.0

func (c *Client) ReportGetUsers(timeUnit, start, duration 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) ScheduleViewMsgId added in v1.1.0

func (c *Client) ScheduleViewMsgId(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 DeviceSettingRequestAlias added in v1.1.0

type DeviceSettingRequestAlias struct {
	Remove []string `json:"remove,omitempty"`
}

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"`
	ChannelId         int                    `json:"channel_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"`
	LargeIcon         string                 `json:"large_icon,omitempty"`
	Intent            map[string]interface{} `json:"intent,omitempty"`
	UriActivity       string                 `json:"uri_activity,omitempty"` // 兼容华为
	UriAction         string                 `json:"uri_action,omitempty"`   //兼容小米
	BadgeAddNum       int                    `json:"badge_add_num,int,omitempty"`
	BadgeClass        string                 `json:"badge_class,omitempty"`
	Sound             string                 `json:"sound,omitempty"`
	ShowBeginTime     string                 `json:"show_begin_time,omitempty"`
	ShowEndTime       string                 `json:"show_end_time,omitempty"`
	DisplayForeground string                 `json:"display_foreground,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"`
	ThreadId         string                 `json:"thread-id,omitempty"`
}

type NotificationQuickApp added in v1.1.0

type NotificationQuickApp struct {
	Title  string                 `json:"title,omitempty"`
	Alert  string                 `json:"alert"`
	Page   string                 `json:"page,omitempty"`
	Extras map[string]interface{} `json:"extras,omitempty"`
}

type NotificationVIOS added in v1.1.0

type NotificationVIOS struct {
	Key string `json:"key,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"
	PlatformQuickApp Platform = "quickapp"
)

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"`
	VIOS     *NotificationVIOS     `json:"vios,omitempty"`
	WinPhone *NotificationWinPhone `json:"winphone,omitempty"`
	QuickApp *NotificationQuickApp `json:"quickapp,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"`
	ThirdPartyChannel map[string]interface{} `json:"third_party_channel,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"`
	SignId       int    `json:"signid,int,omitempty"`
	TempId       int64  `json:"temp_id,long,omitempty"`
	TempPara     string `json:"temp_para,long,omitempty"`
	ActiveFilter bool   `json:"active_filter,bool,omitempty"`
}

type Target

type Target string

Jump to

Keyboard shortcuts

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