private string CreateApplePayload(HubNotification notification) { return(JsonConvert.SerializeObject(new { aps = new { alert = notification.Header } })); }
private string CreateGooglePayload(HubNotification notification) { return(JsonConvert.SerializeObject(new { data = new { message = notification.Header } })); }
public async Task SendNotificationAsync(HubNotification notification) { if (notification == null) { throw new ArgumentNullException("notification"); } string applePayload = CreateApplePayload(notification); string googlePayload = CreateGooglePayload(notification); try { await Task.WhenAll(new[] { _hub.SendAppleNativeNotificationAsync(applePayload), _hub.SendGcmNativeNotificationAsync(googlePayload) }); } catch (MessagingException e) { throw new BadGatewayException(e); } }