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
5 changes: 4 additions & 1 deletion payload/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const (
type ELiveActivityEvent string

const (
// LiveActivityEventStart is used to start a live activity.
LiveActivityEventStart ELiveActivityEvent = "start"

// LiveActivityEventUpdate is used to update an live activity.
LiveActivityEventUpdate ELiveActivityEvent = "update"

Expand Down Expand Up @@ -129,7 +132,7 @@ func (p *Payload) SetStaleDate(staleDate int64) *Payload {
}

// SetEvent sets the aps event type on the payload.
// This can either be `LiveActivityEventUpdate` or `LiveActivityEventEnd`
// This can be `LiveActivityEventStart`, `LiveActivityEventUpdate`, or `LiveActivityEventEnd`
//
// {"aps":{"event": Event }}`
func (p *Payload) SetEvent(event ELiveActivityEvent) *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 @@ -185,6 +185,12 @@ func TestEventEnd(t *testing.T) {
assert.Equal(t, `{"aps":{"event":"end"}}`, string(b))
}

func TestEventStart(t *testing.T) {
payload := NewPayload().SetEvent(LiveActivityEventStart)
b, _ := json.Marshal(payload)
assert.Equal(t, `{"aps":{"event":"start"}}`, string(b))
}

func TestEventUpdate(t *testing.T) {
payload := NewPayload().SetEvent(LiveActivityEventUpdate)
b, _ := json.Marshal(payload)
Expand Down