8000 透传消息 · github-0115/go-getui-api@2a55a28 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a55a28

Browse files
committed
透传消息
1 parent d76654d commit 2a55a28

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

tool/alert.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package tool
2+
3+
type Alert struct {
4+
Title string `json:"title"` //通知标题
10000 5+
Body string `json:"body"` //通知内容
6+
}
7+
8+
func GetAlert(title string, body string) *Alert {
9+
alert := &Alert{
10+
Title: title,
11+
Body: body,
12+
}
13+
return alert
14+
}
15+
16+
func (this *Alert) SetTitle(str string) {
17+
this.Title = str
18+
}
19+
20+
func (this *Alert) SetBody(str string) {
21+
this.Body = str
22+
}

tool/apns.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package tool
2+
3+
//open application templates
4+
type Apns struct {
5+
Alert *Alert `json:"alert"` //
6+
AutoBadge string `json:"autoBadge,omitempty"` //用于计算icon上显示的数字,还可以实现显示数字的自动增减,如“+1”、 “-1”、 “1” 等,计算结果将覆盖badge
7+
Sound string `json:"sound,omitempty"` //通知铃声文件名,无声设置为“com.gexin.ios.silence”
8+
ContentAvailable int `json:"content-available,omitempty"` //推送直接带有透传数据
9+
Category string `json:"category,omitempty"` //在客户端通知栏触发特定的action和button显示
10+
}
11+
12+
func GetApns() *Apns {
13+
apns := &Apns{}
14+
return apns
15+
}
16+
17+
func (this *Apns) SetAlert(alert *Alert) {
18+
this.Alert = alert
19+
}
20+
21+
func (this *Apns) SetAutoBadge(str string) {
22+
this.AutoBadge = str
23+
}
24+
25+
func (this *Apns) SetSound(str string) {
26+
this.Sound = str
27+
}
28+
29+
func (this *Apns) SetContentAvailable(is int) {
30+
this.ContentAvailable = is
31+
}
32+
33+
func (this *Apns) SetCategory(str string) {
34+
this.Category = str
35+
}

tool/message.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ type Message struct {
88
MsgType string `json:"msgtype"` // 消息应用类型,可选项:notification、link、notypopload、transmission
99
}
1010

11+
type messageType struct {
12+
Notification string
13+
Link string
14+
Notypopload string
15+
Transmission string
16+
}
17+
18+
var MsgType = &messageType{"notification", "link", "notypopload", "transmission"}
19+
1120
func GetMessage() *Message {
1221
message := &Message{
1322
IsOffline: true,

tool/multimedia.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package tool
2+
3+
type MultiMedia struct {
4+
Url string `json:"url"` //多媒体资源地址
5+
Type int `json:"type"` //资源类型(1.图片,2.音频, 3.视频)
6+
OnlyWifi bool `json:"only_wifi"` //是否只在wifi环境下加载,如果设置成true,但未使用wifi时,会展示成普通通知
7+
}
8+
9+
func GetMultiMedia(url string, t int, onlyWifi bool) *MultiMedia {
10+
multiMedia := &MultiMedia{
11+
Url: url,
12+
Type: t,
13+
OnlyWifi: onlyWifi,
14+
}
15+
return multiMedia
16+
}
17+
18+
func (this *MultiMedia) SetUrl(str string) {
19+
this.Url = str
20+
}
21+
22+
func (this *MultiMedia) SetType(t int) {
23+
this.Type = t
24+
}
25+
26+
func (this *MultiMedia) SetOnlyWifi(onlyWifi bool) {
27+
this.OnlyWifi = onlyWifi
28+
}

0 commit comments

Comments
 (0)
0