public async Task ScheduleReminders() { if (Device.RuntimePlatform == Device.iOS) { DependencyService.Get <ICancelNotification>()?.CancelAll(); } else { await Notifications.CancelAll(); } foreach (var reminder in Reminders) { var time = (reminder.Time); if (reminder.IsActive) { DateTime startDate = DateTime.Now.Date; DateTime endDate = DateTime.Now.AddMonths(1); startDate = startDate + time; for (int i = 0; i < endDate.Date.Subtract(startDate.Date).Days; i++) { DateTime item = startDate.AddDays(i); bool isMonday = reminder.Monday.IsEnabled && item.DayOfWeek == reminder.Monday.Day; bool isTuesday = reminder.Tuesday.IsEnabled && item.DayOfWeek == reminder.Tuesday.Day; bool isWednesday = reminder.Wednesday.IsEnabled && item.DayOfWeek == reminder.Wednesday.Day; bool isThursday = reminder.Thursday.IsEnabled && item.DayOfWeek == reminder.Thursday.Day; bool isFriday = reminder.Friday.IsEnabled && item.DayOfWeek == reminder.Friday.Day; bool isSaturday = reminder.Saturday.IsEnabled && item.DayOfWeek == reminder.Saturday.Day; bool isSunday = reminder.Sunday.IsEnabled && item.DayOfWeek == reminder.Sunday.Day; if (isMonday || isTuesday || isWednesday || isThursday || isFriday || isSaturday || isSunday) { if (item.CompareTo(DateTime.Now) > 0) { var notification = new Notification() { Id = GetUniqueID(item, Reminders.IndexOf(reminder)), Title = AppResources.NotificationHeader, Message = AppResources.NotificationContent, Date = item, Sound = "notification", Vibrate = false }; if (Device.RuntimePlatform == Device.iOS) { notification.Sound = "notification.caf"; } else { notification.When = TimeSpan.FromTicks(item.Subtract(DateTime.Now).Ticks); } await Notifications.Send(notification); } } } } } }