From dbe5af35d465679c2f9ad34fb1fa983a1a65bcfe Mon Sep 17 00:00:00 2001 From: sideshow Date: Sun, 11 Aug 2024 16:02:35 +1200 Subject: [PATCH] Add ApnsUniqueID identifier for development push --- client.go | 2 +- client_test.go | 3 +++ response.go | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index cd98dd42..d36da1bc 100644 --- a/client.go +++ b/client.go @@ -192,6 +192,7 @@ func (c *Client) PushWithContext(ctx Context, n *Notification) (*Response, error r := &Response{} r.StatusCode = response.StatusCode r.ApnsID = response.Header.Get("apns-id") + r.ApnsUniqueID = response.Header.Get("apns-unique-id") decoder := json.NewDecoder(response.Body) if err := decoder.Decode(r); err != nil && err != io.EOF { @@ -234,5 +235,4 @@ func setHeaders(r *http.Request, n *Notification) { } else { r.Header.Set("apns-push-type", string(PushTypeAlert)) } - } diff --git a/client_test.go b/client_test.go index cca1349f..cfbdb6c6 100644 --- a/client_test.go +++ b/client_test.go @@ -370,9 +370,11 @@ func TestBadPayload(t *testing.T) { func Test200SuccessResponse(t *testing.T) { n := mockNotification() var apnsID = "02ABC856-EF8D-4E49-8F15-7B8A61D978D6" + var apnsUniqueID = "A6739D99-D92A-424B-A91E-BF012365BD4E" server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("apns-id", apnsID) + w.Header().Set("apns-unique-id", apnsUniqueID) w.WriteHeader(http.StatusOK) })) defer server.Close() @@ -380,6 +382,7 @@ func Test200SuccessResponse(t *testing.T) { assert.NoError(t, err) assert.Equal(t, http.StatusOK, res.StatusCode) assert.Equal(t, apnsID, res.ApnsID) + assert.Equal(t, apnsUniqueID, res.ApnsUniqueID) assert.Equal(t, true, res.Sent()) } diff --git a/response.go b/response.go index 7539b41d..55609d39 100644 --- a/response.go +++ b/response.go @@ -135,6 +135,11 @@ type Response struct { // If the value of StatusCode is 410, this is the last time at which APNs // confirmed that the device token was no longer valid for the topic. Timestamp Time + + // An identifier that is only available in the Developement enviroment. Use + // this to query Delivery Log information for the corresponding notification + // in Push Notifications Console. + ApnsUniqueID string } // Sent returns whether or not the notification was successfully sent.