public FirebaseMessagingClient( HttpClientFactory clientFactory, GoogleCredential credential, string projectId) { if (string.IsNullOrEmpty(projectId)) { throw new ArgumentException( "Project ID is required to access messaging service. Use a service account " + "credential or set the project ID explicitly via AppOptions. Alternatively " + "you can set the project ID via the GOOGLE_CLOUD_PROJECT environment " + "variable."); } this.httpClient = new ErrorHandlingHttpClient <FirebaseMessagingException>( new ErrorHandlingHttpClientArgs <FirebaseMessagingException>() { HttpClientFactory = clientFactory.ThrowIfNull(nameof(clientFactory)), Credential = credential.ThrowIfNull(nameof(credential)), RequestExceptionHandler = MessagingErrorHandler.Instance, ErrorResponseHandler = MessagingErrorHandler.Instance, DeserializeExceptionHandler = MessagingErrorHandler.Instance, }); this.fcmClientService = new FCMClientService(new BaseClientService.Initializer() { HttpClientFactory = clientFactory, HttpClientInitializer = credential, }); this.sendUrl = string.Format(FcmSendUrl, projectId); this.restPath = this.sendUrl.Substring(FcmBaseUrl.Length); }
public FCMClientServiceRequest(FCMClientService clientService, string restPath, SendRequest body) : base(clientService) { this.restPath = restPath; this.body = body; this.ModifyRequest = (request) => { AddCommonHeaders(request); }; this.InitParameters(); }
public FirebaseMessagingClient( HttpClientFactory clientFactory, GoogleCredential credential, string projectId) { if (string.IsNullOrEmpty(projectId)) { throw new FirebaseException( "Project ID is required to access messaging service. Use a service account " + "credential or set the project ID explicitly via AppOptions. Alternatively " + "you can set the project ID via the GOOGLE_CLOUD_PROJECT environment " + "variable."); } this.httpClient = clientFactory.ThrowIfNull(nameof(clientFactory)) .CreateAuthorizedHttpClient(credential); this.sendUrl = string.Format(FcmSendUrl, projectId); this.restPath = this.sendUrl.Substring(FcmBaseUrl.Length); this.fcmClientService = new FCMClientService(this.httpClient); }