public void PoppillReminder(int _ID, string _name, string _day, int _count, TimeSpan _time) { long EventID = _ID; TimeSpan Time = _time; string Day = _day; string Title = Day; int Count = _count; string PillName = _name; int recurringday = 0; var Nowdtime = DateTime.Today; int day = GetDay(Day, Nowdtime, ref recurringday); Nowdtime = Nowdtime.AddDays(day); var Datewithtime = Nowdtime.Add(Time); NSDate newNSdatetime = ConvertDateTimeToNSDate(Datewithtime); NSDate nsEndDate = NSDate.DistantFuture; CalendarHelper.Current.EventStore.RequestAccess(EKEntityType.Event, (bool granted, NSError e) => { if (granted) { EKEvent newEvent = EKEvent.FromStore(CalendarHelper.Current.EventStore); newEvent.StartDate = newNSdatetime; newEvent.AddRecurrenceRule(new EKRecurrenceRule(EKRecurrenceFrequency.Weekly, 1, EKRecurrenceEnd.FromEndDate(nsEndDate))); newEvent.Title = "Take your " + Title; newEvent.Notes = "Time to take " + Count + " " + PillName + " pill/s"; newEvent.Calendar = CalendarHelper.Current.EventStore.DefaultCalendarForNewEvents; NSError a; try { // Save Note to Calendar to get UUID CalendarHelper.Current.EventStore.SaveEvent(newEvent, EKSpan.ThisEvent, true, out a); if (a != null) { // Disable UIKit thread checks for a couple of methods var previous = UIApplication.CheckForIllegalCrossThreadCalls; UIApplication.CheckForIllegalCrossThreadCalls = false; var issueView = new UIAlertView("Issues saving Reminder", a.ToString(), null, "ok", null); issueView.Show(); // Restore UIApplication.CheckForIllegalCrossThreadCalls = previous; return; } else { // Disable UIKit thread checks for a couple of methods var previous = UIApplication.CheckForIllegalCrossThreadCalls; UIApplication.CheckForIllegalCrossThreadCalls = false; // Test: Show EventIdentifier var SavedView = new UIAlertView(newEvent.EventIdentifier, "The event has been saved", null, "ok", null); SavedView.Show(); //ViewModel.DataManager.InsertCalID(e.PTPEvent.Id, e.PTPEvent.FilmId, newEvent.Eventidentifier); // ViewModel.DataManager.InsertCalID(e.PTPEvent.Id, e.PTPEvent.FilmId, newEvent.UUID); // Restore UIApplication.CheckForIllegalCrossThreadCalls = previous; } } catch { // Disable UIKit thread checks for a couple of methods var previous = UIApplication.CheckForIllegalCrossThreadCalls; UIApplication.CheckForIllegalCrossThreadCalls = false; var ErrorView = new UIAlertView("Event", "Issues accessing the Calendar to save reminder", null, "ok", null); ErrorView.Show(); // Restore UIApplication.CheckForIllegalCrossThreadCalls = previous; } } else { // Disable UIKit thread checks for a couple of methods var previous = UIApplication.CheckForIllegalCrossThreadCalls; UIApplication.CheckForIllegalCrossThreadCalls = false; var accessDeniedView = new UIAlertView("Access Denied", "user Denied Access to Calendar Data", null, "ok", null); accessDeniedView.Show(); // Restore UIApplication.CheckForIllegalCrossThreadCalls = previous; } }); }