Documentation
¶
Overview ¶
Package baidupush provides a third-party Golang SDK for working with Baidu Cloud Push Service.
Channel contains all the functions for working with the service, including pushing, tagging, querying and timed tasks.
For detailed information, please referring the official documentation: http://push.baidu.com/document
Index ¶
- Constants
- type Channel
- func (bc *Channel) AddTagDevices(tag string, channelIDs []string) ([]TagResult, error)
- func (bc *Channel) CancelTimerTask(timerID string) error
- func (bc *Channel) CreateTag(tag string) (string, error)
- func (bc *Channel) DeleteTag(tag string) (string, error)
- func (bc *Channel) DeleteTagDevices(tag string, channelIDs []string) ([]TagResult, error)
- func (bc *Channel) GetRequestID() int64
- func (bc *Channel) GetTagDevicesNumber(tag string) (int, error)
- func (bc *Channel) PushMsgToAllDevices(msg string, opts url.Values) (string, string, int64, error)
- func (bc *Channel) PushMsgToBatchDevices(channelIDs []string, msg string, opts url.Values) (string, int64, error)
- func (bc *Channel) PushMsgToSingleDevice(channelID string, msg string, opts url.Values) (string, int64, error)
- func (bc *Channel) PushMsgToTaggedDevices(tag, msg string, opts url.Values) (string, string, int64, error)
- func (bc *Channel) QueryMsgStatus(msgID string) (int, []MessageResult, error)
- func (bc *Channel) QueryTagsInfo(opts url.Values) (int, []TagInfo, error)
- func (bc *Channel) QueryTimerRecords(timerID string, opts url.Values) (string, []MessageResult, error)
- func (bc *Channel) QueryTimerTasks(opts url.Values) (int, []TimerResult, error)
- func (bc *Channel) QueryTopicList(opts url.Values) (int, []TopicResult, error)
- func (bc *Channel) QueryTopicRecords(topicID string, opts url.Values) (string, []MessageResult, error)
- func (bc *Channel) ReportDeviceStatistics() (int, []DeviceStatistics, error)
- func (bc *Channel) ReportTopicStatistics(topicID string) (int, []TopicStatistics, error)
- type DeviceStatistics
- type MessageResult
- type TagInfo
- type TagResult
- type TimerResult
- type TopicResult
- type TopicStatistics
Constants ¶
const ( // DefaultBaiduPushService is the default push service host. DefaultBaiduPushService = "api.tuisong.baidu.com" // SDKNameVersion is the SDK name and version. SDKNameVersion = "Golang Baidu Push Service SDK v1.0" // MsgTypeMessage represents a push of message. MsgTypeMessage = 0 // MsgTypeNotice represents a push of notification. MsgTypeNotice = 1 // AndroidDeviceType represents Android platform number for Baidu Push Service. AndroidDeviceType = 3 // AppleDeviceType represents Apple platform number for Baidu Push Service. AppleDeviceType = 4 // DeployStatusDevelop represents development status. DeployStatusDevelop = 1 // DeployStatusProduct represents production status. DeployStatusProduct = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
Channel contains all the methods to interact with Baidu Cloud Push Service.
func NewChannel ¶
NewChannel returns a channel bound with specified paramters.
host: URL address of Baidu Cloud Push Service.
key: API key.
secret: API secret.
device: Device type, AppleDeviceType or AndroidDeviceType.
func NewChannelDefaultHost ¶
NewChannelDefaultHost returns a channel with host set to "api.tuisong.baidu.com"
func (*Channel) AddTagDevices ¶
AddTagDevices adds a batch of devices to a tag group.
tag: name of the tag, must be of length 1-128, "default" is reserved so cannot be used.
channelIDs: a string slice containing channel IDs to add, require at least 1 and at most 10.
func (*Channel) CancelTimerTask ¶
CancelTimerTask cancels timed message not executing yet.
timerID: ID of timed task.
func (*Channel) CreateTag ¶
CreateTag creates an empty tag group.
tag: Name of the tag, must be of length 1-128, "default" is reserved so cannot be used.
func (*Channel) DeleteTag ¶
DeleteTag deletes an existed tag group.
tag: Name of the tag, must be of length 1-128, "default" is reserved so cannot be used.
func (*Channel) DeleteTagDevices ¶
DeleteTagDevices deletes a batch of devices from a tag group.
tag: name of the tag, must be of length 1-128, "default" is reserved so cannot be used.
channelIDs: a string slice containing channel IDs to add, require at least 1 and at most 10.
func (*Channel) GetRequestID ¶
GetRequestID returns request ID returned by server.
func (*Channel) GetTagDevicesNumber ¶
GetTagDevicesNumber returns the number of devices related to tag.
func (*Channel) PushMsgToAllDevices ¶
PushMsgToAllDevices pushes a message to all devices running app.
msg: Message to push
Optional parameters:
msg_type: Type of message, MsgTypeNotice or MsgTypeMessage(default).
msg_expires: 0-604800, defaults to 5 hrs, the time message expired(from the moment on).
deploy_status: Deployment status(for iOS app only), DeployStatusProduct(default) or DeployStatusDevelop.
send_time: The real sending time for timed message, must be at least 60s and at most 1 year.
func (*Channel) PushMsgToBatchDevices ¶
func (bc *Channel) PushMsgToBatchDevices(channelIDs []string, msg string, opts url.Values) (string, int64, error)
PushMsgToBatchDevices pushes a message to a batch of devices.
channelIDs: Channel IDs of devices.
msg: Message to push.
Optional parameters:
msg_type: Type of message, MsgTypeNotice or MsgTypeMessage(default).
msg_expires: 0-604800, defaults to 5 hrs, the time message expired(from the moment on).
topic_id: Name of the topic.
func (*Channel) PushMsgToSingleDevice ¶
func (bc *Channel) PushMsgToSingleDevice(channelID string, msg string, opts url.Values) (string, int64, error)
PushMsgToSingleDevice pushes a message to a single device.
channelID: Channel ID of the device.
msg: Message to push.
Optional parameters:
msg_type: Type of message, MsgTypeNotice or MsgTypeMessage(default).
msg_expires: 0-604800, defaults to 5 hrs, the time message expired(from the moment on).
deploy_status: Deployment status(for iOS app only), DeployStatusProduct(default) or DeployStatusDevelop.
func (*Channel) PushMsgToTaggedDevices ¶
func (bc *Channel) PushMsgToTaggedDevices(tag, msg string, opts url.Values) (string, string, int64, error)
PushMsgToTaggedDevices pushes a message to devices under some tag.
tag: Name of created tag.
msg: Message to push.
Optional parameters:
msg_type: Type of message, MsgTypeNotice or MsgTypeMessage(default).
msg_expires: 0-604800, defaults to 5 hrs, the time message expired(from the moment on).
deploy_status: Deployment status(for iOS app only), DeployStatusProduct(default) or DeployStatusDevelop.
send_time: The real sending time for timed message, must be at least 60s and at most 1 year.
func (*Channel) QueryMsgStatus ¶
func (bc *Channel) QueryMsgStatus(msgID string) (int, []MessageResult, error)
QueryMsgStatus queries message reports via msgID.
msgID: Message ID, could be a json array of IDs.
func (*Channel) QueryTagsInfo ¶
QueryTagsInfo querys tags information of app, opts contains optional parameters below.
Optional parameters:
tag: name of the tag, must be of length 1-128, "default" is reserved so cannot be used.
start: the start position of the returned records, defaults to 0.
limit: the number of records returned, must be 1-100, defaults to 100.
func (*Channel) QueryTimerRecords ¶
func (bc *Channel) QueryTimerRecords(timerID string, opts url.Values) (string, []MessageResult, error)
QueryTimerRecords queries records of timed message via timerID.
timerID: ID of timer task.
Optional parameters:
start: the start position of the returned records, defaults to 0.
limit: the number of records returned, must be 1-100, defaults to 100.
range_start: UNIX timestamp, the start time to query.
range_end: UNIX timestamp, the end time to query.
func (*Channel) QueryTimerTasks ¶
QueryTimerTasks queries timer tasks not executing yet.
Optional parameters:
timer_id: ID of timed task.
start: the start position of the returned records, defaults to 0.
limit: the number of records returned, must be 1-100, defaults to 100.
func (*Channel) QueryTopicList ¶
QueryTopicList returns topics been used.
Optional parameters:
start: the start position of the returned records, defaults to 0.
limit: the number of records returned, must be 1-100, defaults to 100.
func (*Channel) QueryTopicRecords ¶
func (bc *Channel) QueryTopicRecords(topicID string, opts url.Values) (string, []MessageResult, error)
QueryTopicRecords queries records of topic message via topicID.
topicID: Name of the topic.
Optional parameters:
start: the start position of the returned records, defaults to 0.
limit: the number of records returned, must be 1-100, defaults to 100.
range_start: UNIX timestamp, the start time to query.
range_end: UNIX timestamp, the end time to query.
func (*Channel) ReportDeviceStatistics ¶
func (bc *Channel) ReportDeviceStatistics() (int, []DeviceStatistics, error)
ReportDeviceStatistics returns statistics about devices installed app.
func (*Channel) ReportTopicStatistics ¶
func (bc *Channel) ReportTopicStatistics(topicID string) (int, []TopicStatistics, error)
ReportTopicStatistics returns statistic information about number of messages under some topic.
topicID: Name of the topic.
type DeviceStatistics ¶
type DeviceStatistics struct { Day int64 DailyNewUser int DailyLostUser int DailyOnline int AddedupTerm int AvailChnID int }
DeviceStatistics represents statistic about devices installed app.
type MessageResult ¶
MessageResult represents the information about sent message.
type TimerResult ¶
TimerResult represents information about timed task.
type TopicResult ¶
TopicResult represents information of topic.
type TopicStatistics ¶
TopicStatistics represents statistic information about topic.