Skip to content
Merged
Changes from 2 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
10 changes: 6 additions & 4 deletions messaging/messaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"time"

"firebase.google.com/go/internal"
"google.golang.org/api/option/internaloption"
"google.golang.org/api/transport"
)

Expand Down Expand Up @@ -913,13 +914,14 @@ func NewClient(ctx context.Context, c *internal.MessagingConfig) (*Client, error
return nil, errors.New("project ID is required to access Firebase Cloud Messaging client")
}

hc, _, err := transport.NewHTTPClient(ctx, c.Opts...)
c.Opts = append(c.Opts, internaloption.WithDefaultEndpoint(messagingEndpoint))
hc, endpoint, err := transport.NewHTTPClient(ctx, c.Opts...)
if err != nil {
return nil, err
}

return &Client{
fcmClient: newFCMClient(hc, c),
fcmClient: newFCMClient(hc, c, endpoint),
iidClient: newIIDClient(hc),
}, nil
}
Expand All @@ -932,7 +934,7 @@ type fcmClient struct {
httpClient *internal.HTTPClient
}

func newFCMClient(hc *http.Client, conf *internal.MessagingConfig) *fcmClient {
func newFCMClient(hc *http.Client, conf *internal.MessagingConfig, endpoint string) *fcmClient {
client := internal.WithDefaultRetryConfig(hc)
client.CreateErrFn = handleFCMError
client.SuccessFn = internal.HasSuccessStatus
Expand All @@ -944,7 +946,7 @@ func newFCMClient(hc *http.Client, conf *internal.MessagingConfig) *fcmClient {
}

return &fcmClient{
fcmEndpoint: messagingEndpoint,
fcmEndpoint: endpoint,
batchEndpoint: batchEndpoint,
project: conf.ProjectID,
version: version,
Expand Down