@@ -32,8 +32,8 @@ import (
3232)
3333
3434const (
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"
3737
3838 firebaseClientHeader = "X-Firebase-Client"
3939 apiFormatVersionHeader = "X-GOOG-API-FORMAT-VERSION"
@@ -862,17 +862,20 @@ func NewClient(ctx context.Context, c *internal.MessagingConfig) (*Client, error
862862 return nil , errors .New ("project ID is required to access Firebase Cloud Messaging client" )
863863 }
864864
865- hc , endpoint , err := transport .NewHTTPClient (ctx , c .Opts ... )
865+ hc , messagingEndpoint , err := transport .NewHTTPClient (ctx , c .Opts ... )
866866 if err != nil {
867867 return nil , err
868868 }
869869
870- if endpoint == "" {
871- endpoint = messagingEndpoint
870+ batchEndpoint := messagingEndpoint
871+
872+ if messagingEndpoint == "" {
873+ messagingEndpoint = defaultMessagingEndpoint
874+ batchEndpoint = defaultBatchEndpoint
872875 }
873876
874877 return & Client {
875- fcmClient : newFCMClient (hc , c , endpoint ),
878+ fcmClient : newFCMClient (hc , c , messagingEndpoint , batchEndpoint ),
876879 iidClient : newIIDClient (hc ),
877880 }, nil
878881}
@@ -885,7 +888,7 @@ type fcmClient struct {
885888 httpClient * internal.HTTPClient
886889}
887890
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 {
889892 client := internal .WithDefaultRetryConfig (hc )
890893 client .CreateErrFn = handleFCMError
891894
@@ -896,7 +899,7 @@ func newFCMClient(hc *http.Client, conf *internal.MessagingConfig, endpoint stri
896899 }
897900
898901 return & fcmClient {
899- fcmEndpoint : endpoint ,
902+ fcmEndpoint : messagingEndpoint ,
900903 batchEndpoint : batchEndpoint ,
901904 project : conf .ProjectID ,
902905 version : version ,
0 commit comments