Esempio n. 1
0
        private static async Task <NotificationResult> GetErrorResult(HttpResponseMessage response)
        {
            var content = await response.Content.ReadAsStringAsync();

            FcmResponse           fcmResponse = TryGetFcmResponse(content);
            NotificationErrorCode errorCode   = GetErrorCodeFromResponse(fcmResponse);

            return(NotificationResult.WithError(errorCode, $"{response.StatusCode}:{fcmResponse?.Error.Message}; Details: {content}"));
        }
Esempio n. 2
0
        private async Task <NotificationResult> GetErrorResult(HttpResponseMessage response)
        {
            var content = await response.Content.ReadAsStringAsync();

            ApnsError apnsError = TryGetApnsError(content);

            NotificationErrorCode errorCode = GetErrorCodeFromResponse(response, apnsError);

            return(NotificationResult.WithError(errorCode, $"{response.StatusCode}:{content}"));
        }
Esempio n. 3
0
        private async Task <NotificationResult> SendViaHttpV1(string requestBody)
        {
            string token;

            try
            {
                token = await GetAccessToken();
            }
            catch (TokenResponseException e)
            {
                return(NotificationResult.WithError(NotificationErrorCode.AccessDenied, e.Message));
            }

            return(await SendRequest(requestBody, token, notificationUri, true));
        }