-
Notifications
You must be signed in to change notification settings - Fork 1
/
payload.go
49 lines (44 loc) · 1.75 KB
/
payload.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
package apns
const SoundDefault = "default"
type APS struct {
Alert interface{} `json:"alert,omitempty"`
Badge interface{} `json:"badge,omitempty"`
Sound interface{} `json:"sound,omitempty"`
ThreadID string `json:"thread-id,omitempty"`
Category string `json:"category,omitempty"`
ContentAvailable int `json:"content-available,omitempty"`
MutableContent int `json:"mutable-content,omitempty"`
TargetContentID string `json:"target-content-id,omitempty"`
URLArgs []string `json:"url-args,omitempty"`
}
type Alert struct {
Title string `json:"title,omitempty"`
Subtitle string `json:"subtitle,omitempty"`
Body string `json:"body,omitempty"`
LaunchImage string `json:"launch-image,omitempty"`
TitleLocKey string `json:"title-loc-key,omitempty"`
TitleLocArgs []string `json:"title-loc-args,omitempty"`
SubtitleLocKey string `json:"subtitle-loc-key,omitempty"`
SubtitleLocArgs []string `json:"subtitle-loc-args,omitempty"`
LocKey string `json:"loc-key,omitempty"`
LocArgs []string `json:"loc-args,omitempty"`
Action string `json:"action,omitempty"`
ActionLocKey string `json:"action-loc-key,omitempty"`
SummaryArg string `json:"summary-arg,omitempty"`
SummaryArgCount int `json:"summary-arg-count,omitempty"`
}
type Sound struct {
Critical int `json:"critical,omitempty"`
Name string `json:"name,omitempty"`
Volume float32 `json:"volume,omitempty"`
}
func BuildPayload(aps *APS, custom map[string]interface{}) map[string]interface{} {
p := make(map[string]interface{})
for k := range custom {
p[k] = custom[k]
}
if aps != nil {
p["aps"] = aps
}
return p
}