forked from xxgail/PushSDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder.go
54 lines (45 loc) · 915 Bytes
/
builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package PushSDK
import "errors"
type MobileChannel interface {
SendMessage(m *Message, pushId []string) (*Response, error)
}
// 消息体
type Message struct {
Title string
Desc string
ApnsId string
ClickType string
ClickContent string
Err error
}
func NewMessage() *Message {
return &Message{
ClickType: "app",
}
}
func (m *Message) SetTitle(str string) *Message {
if str == "" {
m.Err = errors.New("推送标题不能为空")
}
m.Title = str
return m
}
func (m *Message) SetContent(str string) *Message {
if str == "" {
m.Err = errors.New("推送内容不能为空")
}
m.Desc = str
return m
}
func (m *Message) SetApnsId(str string) *Message {
m.ApnsId = str
return m
}
func (m *Message) SetClickType(str string) *Message {
m.ClickType = str
return m
}
func (m *Message) SetClickContent(str string) *Message {
m.ClickContent = str
return m
}