private async Task SendAndroidNotificationAsync(string notificationsId, NotificationType notificationType, string message, OrderHistoryBackendContract order = null) { var gcmMessage = new AndroidNotification { Data = new AndroidPositionFields { Entity = EventsAndEntities.GetEntity(notificationType), Event = EventsAndEntities.GetEvent(notificationType), Order = order, Message = message } }; var payload = gcmMessage.ToJson(ignoreNulls: true); try { var hub = CustomNotificationHubClient.CreateClientFromConnectionString(_connectionString, _hubName); await hub.SendGcmNativeNotificationAsync(payload, new[] { notificationsId }); } catch (Exception e) { _log.WriteError(nameof(SendAndroidNotificationAsync), payload, e); } }
private async Task SendIosNotificationAsync(string notificationsId, NotificationType notificationType, string message, OrderHistoryBackendContract order = null) { var apnsMessage = new IosNotification { Aps = new IosPositionFields { Alert = message, Type = notificationType, Order = order } }; var payload = apnsMessage.ToJson(ignoreNulls: true); try { var hub = CustomNotificationHubClient.CreateClientFromConnectionString(_connectionString, _hubName); await hub.SendAppleNativeNotificationAsync(payload, new[] { notificationsId }); } catch (Exception e) { _log.WriteError(nameof(SendIosNotificationAsync), payload, e); } }