File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ type aps struct {
17
17
ContentAvailable int `json:"content-available,omitempty"`
18
18
URLArgs []string `json:"url-args,omitempty"`
19
19
Sound string `json:"sound,omitempty"`
20
+ MutableContent int `json:"mutable-content,omitempty"`
20
21
}
21
22
22
23
type alert struct {
@@ -96,6 +97,15 @@ func (p *Payload) ContentAvailable() *Payload {
96
97
return p
97
98
}
98
99
100
+ // MutableContent sets the aps mutable-content on the payload to 1.
101
+ // This will indicate to the to the system to call your Notification Service
102
+ // extension to mutate or replace the notification's content.
103
+ // {"aps":{"mutable-content":1}}
104
+ func (p * Payload ) MutableContent () * Payload {
105
+ p .aps ().MutableContent = 1
106
+ return p
107
+ }
108
+
99
109
// Custom payload
100
110
101
111
// Custom sets a custom key and value on the payload.
Original file line number Diff line number Diff line change @@ -50,6 +50,12 @@ func TestContentAvailable(t *testing.T) {
50
50
assert .Equal (t , `{"aps":{"content-available":1}}` , string (b ))
51
51
}
52
52
53
+ func TestMutableContent (t * testing.T ) {
54
+ payload := NewPayload ().MutableContent ()
55
+ b , _ := json .Marshal (payload )
56
+ assert .Equal (t , `{"aps":{"mutable-content":1}}` , string (b ))
57
+ }
58
+
53
59
func TestCustom (t * testing.T ) {
54
60
payload := NewPayload ().Custom ("key" , "val" )
55
61
b , _ := json .Marshal (payload )
You can’t perform that action at this time.
0 commit comments