@@ -32,8 +32,8 @@ import (
32
32
)
33
33
34
34
const (
35
- messagingEndpoint = "https://fcm.googleapis.com/v1"
36
- batchEndpoint = "https://fcm.googleapis.com/batch"
35
+ defaultMessagingEndpoint = "https://fcm.googleapis.com/v1"
36
+ defaultBatchEndpoint = "https://fcm.googleapis.com/batch"
37
37
38
38
firebaseClientHeader = "X-Firebase-Client"
39
39
apiFormatVersionHeader = "X-GOOG-API-FORMAT-VERSION"
@@ -862,17 +862,20 @@ func NewClient(ctx context.Context, c *internal.MessagingConfig) (*Client, error
862
862
return nil , errors .New ("project ID is required to access Firebase Cloud Messaging client" )
863
863
}
864
864
865
- hc , endpoint , err := transport .NewHTTPClient (ctx , c .Opts ... )
865
+ hc , messagingEndpoint , err := transport .NewHTTPClient (ctx , c .Opts ... )
866
866
if err != nil {
867
867
return nil , err
868
868
}
869
869
870
- if endpoint == "" {
871
- endpoint = messagingEndpoint
870
+ batchEndpoint := messagingEndpoint
871
+
872
+ if messagingEndpoint == "" {
873
+ messagingEndpoint = defaultMessagingEndpoint
874
+ batchEndpoint = defaultBatchEndpoint
872
875
}
873
876
874
877
return & Client {
875
- fcmClient : newFCMClient (hc , c , endpoint ),
878
+ fcmClient : newFCMClient (hc , c , messagingEndpoint , batchEndpoint ),
876
879
iidClient : newIIDClient (hc ),
877
880
}, nil
878
881
}
@@ -885,7 +888,7 @@ type fcmClient struct {
885
888
httpClient * internal.HTTPClient
886
889
}
887
890
888
- func newFCMClient (hc * http.Client , conf * internal.MessagingConfig , endpoint string ) * fcmClient {
891
+ func newFCMClient (hc * http.Client , conf * internal.MessagingConfig , messagingEndpoint string , batchEndpoint string ) * fcmClient {
889
892
client := internal .WithDefaultRetryConfig (hc )
890
893
client .CreateErrFn = handleFCMError
891
894
@@ -896,7 +899,7 @@ func newFCMClient(hc *http.Client, conf *internal.MessagingConfig, endpoint stri
896
899
}
897
900
898
901
return & fcmClient {
899
- fcmEndpoint : endpoint ,
902
+ fcmEndpoint : messagingEndpoint ,
900
903
batchEndpoint : batchEndpoint ,
901
904
project : conf .ProjectID ,
902
905
version : version ,
0 commit comments