Documentation ¶
Overview ¶
Package baidu provides Baidu Push client implementation, and a push.Pusher implementation for skygear-server.
Currently only push notification to Android is supported.
Index ¶
Constants ¶
const BaiduPushPackageVersion = "0.1"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AndroidNotificationMsg ¶
type AndroidNotificationMsg struct { Title string `json:"title"` Description string `json:"description"` NotificationBuilderID int `json:"notification_builder_id,omitempty"` NotificationBasicStyle int `json:"notification_basic_style,omitempty"` OpenType int `json:"open_type,omitempty"` URL string `json:"url,omitempty"` PkgContent string `json:"pkg_content,omitempty"` CustomContent map[string]interface{} `json:"custom_content,omitempty"` }
AndroidNotificationMsg represents a notification of Android devices.
func NewAndroidNotificationMsg ¶
func NewAndroidNotificationMsg(title, description string) AndroidNotificationMsg
NewAndroidNotificationMsg returns a new AndroidNotificationMsg.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is a baidu push client.
func (*Client) PushAllDevice ¶
func (c *Client) PushAllDevice(req PushAllDeviceRequest) (*PushResponse, error)
PushAllDevice issues a "push/all" request to baidu push server.
func (*Client) PushSingleDevice ¶
func (c *Client) PushSingleDevice(req PushSingleDeviceRequest) (*PushResponse, error)
PushSingleDevice issues a "push/single_device" request to baidu push server.
type DeviceType ¶
type DeviceType int
DeviceType specifies the kind of device to send a notification. Currently only Android is supported. This type exists for documentation purpose.
const ( DeviceTypeUnspecified DeviceType = 0 DeviceTypeAndroid DeviceType = 3 DeviceTypeIOS DeviceType = 4 )
Types of device that can be sent a notification via baidu push. Note that DeviceTypeUnspecified is not a valid value in a push request.
type Error ¶
type Error struct { // Request ID that leads to this error. RequestID int `json:"request_id"` // See http://push.baidu.com/doc/restapi/error_code for a complete // list of error codes. Code int `json:"error_code"` // A human readable message about the error in Simplified Chinese. Msg string `json:"error_msg"` }
An Error is an erroneous response returned by baidu push server.
type PushAllDeviceRequest ¶
type PushAllDeviceRequest struct { MsgType int Msg AndroidNotificationMsg MsgExpires int DeployStatus int SendTime int }
PushAllDeviceRequest represents a push request to all devices registered to an account. It exists for testing purpose and no skygear's API is using it.
type PushResponse ¶
type PushResponse struct { RequestID int `json:"request_id"` ResponseParams PushResponseParams `json:"response_params"` }
PushResponse is the response returned from a successful push request (e.g. PushAllDeviceRequest & PushSingleDeviceRequest)
type PushResponseParams ¶
PushResponseParams is the params returned from a successful push request.
type PushSingleDeviceRequest ¶
type PushSingleDeviceRequest struct { ChannelID string MsgType int Msg AndroidNotificationMsg MsgExpires int // in seconds DeployStatus int // only applicable in iOS }
PushSingleDeviceRequest represents a push request to a single device. See http://push.baidu.com/doc/restapi/restapi#-post-rest-3-0-push-single_device.
func NewPushSingleDeviceRequest ¶
func NewPushSingleDeviceRequest(channelID string, Msg AndroidNotificationMsg) PushSingleDeviceRequest
NewPushSingleDeviceRequest returns a NewPushSingleDeviceRequest