From 8c4111726360ef561225b64cc3cbf4e7e3402978 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 24 Oct 2024 11:42:40 +0800 Subject: [PATCH] Fix n.Expiration.IsZero and support pushtotalk push notification (#235) --- client_test.go | 11 +++++++++++ notification.go | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/client_test.go b/client_test.go index 2f2045c..60fd058 100644 --- a/client_test.go +++ b/client_test.go @@ -352,6 +352,17 @@ func TestPushTypeLiveActivityHeader(t *testing.T) { assert.NoError(t, err) } +func TestPushTypePushToTalkHeader(t *testing.T) { + n := mockNotification() + n.PushType = apns.PushTypePushToTalk + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, "pushtotalk", 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 5cbc921..54c8caf 100644 --- a/notification.go +++ b/notification.go @@ -71,6 +71,12 @@ const ( // push type is recommended for iOS. It is not available on macOS, tvOS, // watchOS and iPadOS. PushTypeLiveActivity EPushType = "liveactivity" + + // PushTypePushToTalk is used for notifications that provide information about the + // push to talk. If you set this push type, the apns-topic header field + // must use your app’s bundle ID with.voip-ptt appended to the end. + // The pushtotalk push type isn’t available on watchOS, macOS, and tvOS. It’s recommended on iOS and iPadOS. + PushTypePushToTalk EPushType = "pushtotalk" ) const (