Can not save to native calendar - Xamarin - IOS

0

I'm saving an event on the IOS native calendar through the code below, because the simulator works perfectly, but when I do it right on the iPhone device this code does not work. I did two tests the first one opening the calendar for the user to view and then save and in that case it shows the message that it is not possible to save the event, in the second I had to save it directly without needing the user to click on save from the calendar, in which case it saved the event id but does not appear in the calendar, but if it searches for the ios it finds the event we click on the event opens the calendar and the event does not appear. Has anyone had this problem or do you have any idea what it might be? I already used the Xamarin example without changing anything and it gave the same problem.

******* FIRST TEST *******

EventKitUI.EKEventEditViewController eventController = new EventKitUI.EKEventEditViewController();
DateTime reference = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2001, 1, 1, 0, 0, 0));
eventController.Event = EKEvent.FromStore(App.Current.EventStore);
eventController.Event.StartDate = (NSDate)DateTime.Now.AddMinutes(10);
eventController.Event.EndDate = (NSDate)DateTime.Now.AddMinutes(40);
eventController.Event.Title = "TITLE";
eventController.Event.Notes = "NOTE";
eventControllerDelegate = new CreateEventEditViewDelegate(eventController);
eventController.EditViewDelegate = eventControllerDelegate;
PresentViewController(eventController, true, null);

******* SECOND TEST *******

EKEvent newEvent = EKEvent.FromStore(App.Current.EventStore);
newEvent.AddAlarm(EKAlarm.FromDate((NSDate)DateTime.Now.AddMinutes(5)));
newEvent.StartDate = (NSDate)DateTime.Now.AddMinutes(10);
newEvent.EndDate = (NSDate)DateTime.Now.AddMinutes(40);
newEvent.Title = "TITLE";
newEvent.Notes = "NOTE";
newEvent.Calendar = App.Current.EventStore.DefaultCalendarForNewEvents;
NSError e;
App.Current.EventStore.SaveEvent(newEvent, EKSpan.ThisEvent, out e);
if (e != null)
{
new UIAlertView("Err Saving Event", e.ToString(), null, "ok", null).Show();
return;
}
else
{
new UIAlertView("Event Saved", "Event ID: " + newEvent.EventIdentifier, null, "ok", null).Show();
}
    
asked by anonymous 20.08.2016 / 01:49

0 answers