Cannot save to native calendar - Xamarin - IOS

Asked

Viewed 52 times

0

I am saving an event in the native calendar of IOS through the code below, by the simulator works perfectly, but when I do right on the device of the iPhone this code does not work. I did two tests the first opening the calendar for the user to view and then save and in this case displays the message that it is not possible to save the event, in the second I had saved direct without needing the user to click on the calendar save, in this case it saved generated the Event Id but it does not appear in the calendar, but if you search for Ios it finds the event we click on the calendar and the event does not appear. Has anyone ever had this problem or any idea what it might be? I’ve used the example of Xamarin without changing anything and 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();
}
  • 2

    Could you translate your question? You are on Stackoverflow in English.

  • I’m saving an event normally in the native IOS calendar through the code above by the simulator, but when I do right on the iPhone device this code does not work displaying the message that is not possible to save the event

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.