jpush

package module
v0.0.0-...-52180d0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 11 Imported by: 0

README

JPush GO SDK

中文文档

JPush GO SDK is the official Golang SDK for JPush, a push notification service. Since the official Go SDK only provides a project without any files, this SDK was developed to fill in the gap. Please refer to the unit test code for usage instructions.

Feature List

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

Unit Testing

  1. Add APP_KEY, MASTER_SECRET, and REGISTRATION_ID to the environment variables.
  2. Run go test .

How to Use

Please refer to the unit test code for usage instructions.

Note

The VIP class interfaces and Admin API v1 are not implemented due to lack of permission. If needed, you can submit a pull request.

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) ReportReceived

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

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"`
}

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 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 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"`
}

Jump to

Keyboard shortcuts

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