public async Task Handle(RequestAdded args) { try { string deviceId = args.DeviceId;//This is an assumption here var notification = CreateAndroidPartnerAppNotification(deviceId); // this statment is executed, and the text log file will contains this line TracingSystem.TraceInformation("Before Send Google Notification"); await SendersFacade.PartnerSender.SendAsync(notification); } catch (Exception ex) { TracingSystem.TraceException(ex); } }
public async Task SendAsync(GoogleNotification notification) { TracingSystem.TraceInformation("Inside Send Google notification"); var json = notification.GetJson(); var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json"); var requestUri = "https://fcm.googleapis.com/fcm/send"; using (var message = await Client.PostAsync(requestUri, content)) { message.EnsureSuccessStatusCode(); var result = await message.Content.ReadAsAsync <GoogleNotificationResult>(); if (result.Failure > 0) { throw new Exception($"Sending Failed : {result.Results.FirstOrDefault().Error}"); } } }