From c9bd799e82fcf107578b65fa581d00cebb6a38fd Mon Sep 17 00:00:00 2001 From: Eugene Molodovsky Date: Thu, 20 Oct 2022 22:05:40 +0600 Subject: [PATCH] Add live activity type to EPushType --- client_test.go | 11 +++++++++++ notification.go | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/client_test.go b/client_test.go index 83061ddb..cca1349f 100644 --- a/client_test.go +++ b/client_test.go @@ -322,6 +322,17 @@ func TestPushTypeMDMHeader(t *testing.T) { assert.NoError(t, err) } +func TestPushTypeLiveActivityHeader(t *testing.T) { + n := mockNotification() + n.PushType = apns.PushTypeLiveActivity + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, "liveactivity", r.Header.Get("apns-push-type")) + })) + defer server.Close() + _, err := mockClient(server.URL).Push(n) + assert.NoError(t, err) +} + func TestAuthorizationHeader(t *testing.T) { n := mockNotification() token := mockToken() diff --git a/notification.go b/notification.go index 69bf312d..37b2b438 100644 --- a/notification.go +++ b/notification.go @@ -63,6 +63,14 @@ const ( // contact the MDM server. If you set this push type, you must use the topic // from the UID attribute in the subject of your MDM push certificate. PushTypeMDM EPushType = "mdm" + + // PushTypeLiveActivity is used for Live Activities that display various + // real-time information. If you set this push type, the topic field must + // use your app’s bundle ID with push-type.liveactivity appended to the end. + // The live activity push supports only token-based authentication. This + // push type is recommended for iOS. It is not available on macOS, tvOS, + // watchOS and iPadOS. + PushTypeLiveActivity EPushType = "liveactivity" ) const (