Skip to content

Commit 5741cc6

Browse files
authored
Getting more detailed errors from FCM back-end service (#197)
1 parent 095fb97 commit 5741cc6

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

messaging/messaging.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,9 @@ func (c *Client) makeSendRequest(ctx context.Context, req *fcmRequest) (string,
618618
Method: http.MethodPost,
619619
URL: fmt.Sprintf("%s/projects/%s/messages:send", c.fcmEndpoint, c.project),
620620
Body: internal.NewJSONEntity(req),
621+
Opts: []internal.HTTPOption{internal.WithHeader("X-GOOG-API-FORMAT-VERSION", "2")},
621622
}
623+
622624
resp, err := c.client.Do(ctx, request)
623625
if err != nil {
624626
return "", err

messaging/messaging_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,9 @@ func checkFCMRequest(t *testing.T, b []byte, tr *http.Request, want map[string]i
10201020
if h := tr.Header.Get("Authorization"); h != "Bearer test-token" {
10211021
t.Errorf("Authorization = %q; want = %q", h, "Bearer test-token")
10221022
}
1023+
if h := tr.Header.Get("X-GOOG-API-FORMAT-VERSION"); h != "2" {
1024+
t.Errorf("X-GOOG-API-FORMAT-VERSION = %q; want = %q", h, "2")
1025+
}
10231026
}
10241027

10251028
func checkIIDRequest(t *testing.T, b []byte, tr *http.Request, op string) {

0 commit comments

Comments
 (0)