private void LogNotification(INotification notification, NotificationStatus status) { if (notification.GetType() == typeof(AppleNotification)) { var noti = (AppleNotification)notification; var type = (NotificationType)Enum.Parse(typeof(NotificationType), noti.Payload.Category); _pushNotificationService.AddNotificationLog(noti.Payload.Alert.Body, noti.DeviceToken, DeviceType.IOS, type, status); } else if (notification.GetType() == typeof(GcmNotification)) { var noti = (GcmNotification)notification; JavaScriptSerializer json_serializer = new JavaScriptSerializer(); var data = (Dictionary <string, object>)json_serializer.DeserializeObject(noti.JsonData); var type = NotificationType.MessageAlert; //(NotificationType)Enum.Parse(typeof(NotificationType), data["type"].ToString()); var pList = new List <PushNotificationViewModel>(); noti.RegistrationIds.ForEach(tok => { pList.Add(new PushNotificationViewModel { DeviceId = tok, DeviceType = DeviceType.Android, Message = noti.JsonData, Status = status, Type = type }); }); _pushNotificationService.AddNotificationLog(pList); } }