goPushSdk

package module
v0.0.0-...-bf0d16c Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

README

go-meizu-push-sdk

GoDoc Reference Build Status Coverage Status Go Report Card License

Installation

   go get github.com/MEIZUPUSH/go-meizu-push-sdk

订阅相关接口

  • API 列表
    func ChangeAllSwitch(appId string, pushId string, subSwitch bool, appKey string) PushResponse
    func ChangeRegisterSwitch(appId string, pushId string, msgType string, subSwitch bool, appKey string) PushResponse
    func GetRegisterSwitch(appId string, pushId string, appKey string) PushResponse
    func GetSubAlias(appId string, pushId string, appKey string) PushResponse
    func GetSubTags(appId string, pushId string, appKey string) PushResponse
    func Register(appId string, appKey string, deviceId string) PushResponse
    func ResolvePushResponse(res *httpclient.Response, err error) PushResponse
    func SubscribeAlias(appId string, pushId string, alias string, appKey string) PushResponse
    func SubscribeTags(appId string, pushId string, tags string, appKey string) PushResponse
    func UnSubAllTags(appId string, pushId string, appKey string) PushResponse
    func UnSubscribeAlias(appId string, pushId string, appKey string) PushResponse
    func UnSubscribeTags(appId string, pushId string, tags string, appKey string) PushResponse

NOTE: 以test单元测试的方法说明其中一种api的使用方式

  • 获取订阅开关状态
func TestGetRegisterSwitch(t *testing.T) {
	message := GetRegisterSwitch(APP_ID,PUSH_ID,APP_KEY)
	fmt.Println("current message "+message.message)
	if(message.code != 200){
		t.Error("Status Code not 200")
	}
}

推送相关接口

  • API 列表
    func PushNotificationMessageByPushId(appId string, pushIds string, messageJson string, appKey string) PushResponse
    func PushThroughMessageByPushId(appId string, pushIds string, messageJson string, appKey string) PushResponse

NOTE: 以test单元测试的方法说明其中一种api的使用方式

  • 推送透传消息
func TestPushThroughMessageByPushId(t *testing.T) {
	messageJson := `{"test_throught_message": "message"}`
	message := PushThroughMessageByPushId(APP_ID,PUSH_ID,buildThroughMessage(messageJson),APP_KEY)

	fmt.Println("TestPushThroughMessageByPushId ",message.message)

	if message.code != 200 {
		t.Error("Status Code not 200")
	}
}    
  • 推送通知栏消息
func TestPushNotificationMessageByPushId(t *testing.T) {
    //使用通知栏构建工具方法快速构建通知栏json
	json := BuildNotificationMessage().
		noticeBarType(2).
		noticeTitle("标题go").
		noticeContent("测试内容").toJson()
	message := PushNotificationMessageByPushId(APP_ID,PUSH_ID,json,APP_KEY)

	fmt.Println("TestPushNotificationMessageByPushId ",message.message)

	if message.code != 200 {
		t.Error("Status Code not 200")
	}

}

NOTE: 详情请参考meizu-push-godoc

Documentation

Index

Constants

View Source
const (
	SERVER      = "https://api-push.meizu.com/garcia/api/client/"
	STATUS_CODE = 200
	//服务端SDK调用API的应用的私钥Secret Key为 appSecret
	PUSH_API_SERVER = "https://api-push.meizu.com"
)
View Source
const (
	APP_ID  = "100999"
	APP_KEY = "531732bc45324098978bf41c6954c09e"
	PUSH_ID = "862891030007404100999"

	NOTIFICATION_SWITCH    = "0"
	THROUGH_MESSAGE_SWITCH = "1"
)

Variables

This section is empty.

Functions

func GenerateSign

func GenerateSign(params map[string]string, appKey string) string

md5 sign

func PushParamMD5

func PushParamMD5(paramstr string) string

Types

type AdvanceInfo

type AdvanceInfo struct {
	Suspend             int              `json:"suspend"`
	ClearNoticeBar      int              `json:"clearNoticeBar"`
	FixDisplay          int              `json:"fixDisplay"`
	FixStartDisplayTime string           `json:"fixStartDisplayTime"`
	FixEndDisplayTime   string           `json:"fixEndDisplayTime"`
	NotificationType    NotificationType `json:"notificationType"`
}
"advanceInfo": {
       "suspend":是否通知栏悬浮窗显示 (1 显示  0 不显示) 【int 非必填,默认1】
       "clearNoticeBar":是否可清除通知栏 (1 可以  0 不可以) 【int 非必填,默认1】
       "fixDisplay":是否定时展示 (1 是  0 否) 【int 非必填,默认0】
       "fixStartDisplayTime": 定时展示开始时间(yyyy-MM-dd HH:mm:ss) 【str 非必填】
       "fixEndDisplayTime ": 定时展示结束时间(yyyy-MM-dd HH:mm:ss) 【str 非必填】
       "notificationType": {
           "vibrate":  震动 (0关闭  1 开启) ,  【int 非必填,默认1】
           "lights":   闪光 (0关闭  1 开启), 【int 非必填,默认1】
           "sound":   声音 (0关闭  1 开启), 【int 非必填,默认1】
       }
   }

type ClickTypeInfo

type ClickTypeInfo struct {
	ClickType       int                    `json:"clickType"`
	Url             string                 `json:"url"`
	Parameters      map[string]interface{} `json:"parameters"`
	Activity        string                 `json:"activity"`
	CustomAttribute string                 `json:"customAttribute"`
}
"clickTypeInfo": {
       "clickType": 点击动作 (0,"打开应用"),(1,"打开应用页面"),(2,"打开URI页面"),(3, "应用客户端自定义")【int 非必填,默认为0】
       "url": URI页面地址, 【string clickType为打开URI页面时,必填, 长度限制1000字节】
       "parameters":参数 【JSON格式】【非必填】
       "activity":应用页面地址 【string clickType为打开应用页面时,必填, 长度限制1000字节】
       "customAttribute":应用客户端自定义【string clickType为应用客户端自定义时,必填, 输入长度为1000字节以内】
   }

type NoticeBarInfo

type NoticeBarInfo struct {
	NoticeBarType int    `json:"noticeBarType"`
	Title         string `json:"title"`
	Content       string `json:"content"`
}
"noticeBarInfo": {
    "noticeBarType": 通知栏样式(0, "标准"),(2, "安卓原生")【int 非必填,值为0】
    "title": 推送标题, 【string 必填,字数限制1~32字符】
    "content": 推送内容, 【string 必填,字数限制1~100字符】
}

type NoticeExpandInfo

type NoticeExpandInfo struct {
	NoticeExpandType    int    `json:"noticeExpandType"`
	NoticeExpandContent string `json:"noticeExpandContent"`
}

type NotificationMessage

type NotificationMessage struct {
	NoticeBarInfo    NoticeBarInfo    `json:"noticeBarInfo"`
	NoticeExpandInfo NoticeExpandInfo `json:"noticeExpandInfo"`
	ClickTypeInfo    ClickTypeInfo    `json:"clickTypeInfo"`
	PushTimeInfo     PushTimeInfo     `json:"pushTimeInfo"`
	AdvanceInfo      AdvanceInfo      `json:"advanceInfo"`
}

func BuildNotificationMessage

func BuildNotificationMessage() NotificationMessage

type NotificationType

type NotificationType struct {
	Vibrate int `json:"vibrate"`
	Lights  int `json:"lights"`
	Sound   int `json:"sound"`
}

type PushResponse

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

func ChangeAllSwitch

func ChangeAllSwitch(appId string, pushId string, subSwitch bool, appKey string) PushResponse

修改所有开关状态

func ChangeRegisterSwitch

func ChangeRegisterSwitch(appId string, pushId string, msgType string, subSwitch bool, appKey string) PushResponse

修改订阅开关状态

func GetRegisterSwitch

func GetRegisterSwitch(appId string, pushId string, appKey string) PushResponse

获取订阅开关状态

func GetSubAlias

func GetSubAlias(appId string, pushId string, appKey string) PushResponse

获取订阅别名

func GetSubTags

func GetSubTags(appId string, pushId string, appKey string) PushResponse

获取订阅标签

func GetTaskStatistics

func GetTaskStatistics(appId string, taskId string, appKey string) PushResponse

获取任务推送统计

func PushNotificationMessageByAlias

func PushNotificationMessageByAlias(appId string, alias string, messageJson string, appKey string) PushResponse

别名推送接口(通知栏消息)

func PushNotificationMessageByPushId

func PushNotificationMessageByPushId(appId string, pushIds string, messageJson string, appKey string) PushResponse

pushId推送接口(通知栏消息)

func PushThroughMessageByAlias

func PushThroughMessageByAlias(appId string, alias string, messageJson string, appKey string) PushResponse

别名推送接口(透传消息

func PushThroughMessageByPushId

func PushThroughMessageByPushId(appId string, pushIds string, messageJson string, appKey string) PushResponse

*

  • 通过PushId推送透传消息

func Register

func Register(appId string, appKey string, deviceId string) PushResponse

android 客户端订阅接口

func ResolvePushResponse

func ResolvePushResponse(res *httpclient.Response, err error) PushResponse

resolve push response

func SubscribeAlias

func SubscribeAlias(appId string, pushId string, alias string, appKey string) PushResponse

别名订阅

func SubscribeTags

func SubscribeTags(appId string, pushId string, tags string, appKey string) PushResponse

标签订阅

func UnSubAllTags

func UnSubAllTags(appId string, pushId string, appKey string) PushResponse

取消订阅所有标签

func UnSubscribeAlias

func UnSubscribeAlias(appId string, pushId string, appKey string) PushResponse

取消别名订阅

func UnSubscribeTags

func UnSubscribeTags(appId string, pushId string, tags string, appKey string) PushResponse

取消标签订阅

type PushTimeInfo

type PushTimeInfo struct {
	OffLine   int `json:"offLine"`
	ValidTime int `json:"validTime"`
}
"pushTimeInfo": {
       "offLine": 是否进离线消息(0 否 1 是[validTime]) 【int 非必填,默认值为1】
       "validTime": 有效时长 (1到72 小时内的正整数) 【int offLine值为1时,必填,默认24】
   }

type T_AdvanceInfo

type T_AdvanceInfo struct {
	FixSpeed     int `json:"fixSpeed"`
	FixSpeedRate int `json:"fixSpeedRate"`
}

type T_PushTimeInfo

type T_PushTimeInfo struct {
	OffLine   int `json:"offLine"`
	ValidTime int `json:"validTime"`
}

type ThroughMessage

type ThroughMessage struct {
	Title        string         `json:"title"`
	Content      string         `json:"content"`
	PushTimeInfo T_PushTimeInfo `json:"pushTimeInfo"`
	AdvanceInfo  T_AdvanceInfo  `json:"advanceInfo"`
}

这里所有的字段都是头字母大写

Jump to

Keyboard shortcuts

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