https://github.com/zwczou/jpush
极光推送go客户端,支持定时推送,推送,设备标签别名更改等
https://github.com/zwczou/jpush
go jiguang jpush
Last synced: about 1 year ago
JSON representation
极光推送go客户端,支持定时推送,推送,设备标签别名更改等
- Host: GitHub
- URL: https://github.com/zwczou/jpush
- Owner: zwczou
- Created: 2017-10-11T06:44:39.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-09-18T08:12:31.000Z (almost 5 years ago)
- Last Synced: 2025-03-29T13:04:18.832Z (about 1 year ago)
- Topics: go, jiguang, jpush
- Language: Go
- Homepage: https://godoc.org/github.com/zwczou/jpush
- Size: 19.5 KB
- Stars: 27
- Watchers: 4
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
极光推送Golang客户端
===
目前支持
* Push API v3
* Schedule API v3
* Device API v3
### 安装
go get github.com/zwczou/jpush
### 使用
1. 初始化客户端
```go
client := jpush.New("key", "secret")
```
2. 获取推送唯一标识符 cid
```go
cidList, err = client.PushCid(1, "push")
```
3. 推送消息
```go
payload := &jpush.Payload{
Platform: jpush.NewPlatform().All(),
Audience: jpush.NewAudience().All().SetTag("abc", "ef").SetTagAnd("filmtest"),
Notification: &jpush.Notification{
Alert: "test",
},
Options: &jpush.Options{
TimeLive: 60,
ApnsProduction: false,
},
}
msgId, err = client.Push(payload)
// msgId, err = client.PushValidate(payload)
```
4. 创建计划任务
```
client.ScheduleCreate
```
5. 方便扩展
如果库没有实现你想使用的方法,可以使用`client.Do`扩展
```go
// 获取任务的所有msg_id
var out struct {
MsgIds []struct {
MsgId string `json:"msg_id"`
} `json:"msgids"`
}
err := client.Do(http.MethodGet, "/schedules/"+scheduleId+"/msg_ids", nil, &out)
```