Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions payload/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ func (p *Payload) Custom(key string, val interface{}) *Payload {
return p
}

// UnsetCustom unsets a custom key and value on the payload.
// This will delete custom key/value data from the notification payload at root level.
//
// {"aps":{}}
func (p *Payload) UnsetCustom(key string) *Payload {
delete(p.content, key)
return p
}

// Alert dictionary

// AlertTitle sets the aps alert title on the payload.
Expand Down
6 changes: 6 additions & 0 deletions payload/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ func TestCustomMap(t *testing.T) {
assert.Equal(t, `{"aps":{},"key":{"map":1}}`, string(b))
}

func TestUnsetCustom(t *testing.T) {
payload := NewPayload().Custom("key", "val").UnsetCustom("key")
b, _ := json.Marshal(payload)
assert.Equal(t, `{"aps":{}}`, string(b))
}

func TestAlertTitle(t *testing.T) {
payload := NewPayload().AlertTitle("hello")
b, _ := json.Marshal(payload)
Expand Down