Xamarin iOS & EventKit iOS 9 - Create calendar entry

ChristianSchaffer.5984ChristianSchaffer.5984 DEMember
edited November 2015 in Xamarin.iOS

my code works well on iOS 7, 8 and in simulator with iOS 9, but on a iOS 9 device nothing happen and no error message appears.

private void SaveVorstellung(Vorstellung vorstellung, out NSError error)
    {
        string eventId = ViewModel.GetCalendarID(vorstellung.Id, vorstellung.FilmId);
        if (String.IsNullOrEmpty(eventId))
        {
            EKEvent newEvent = EKEvent.FromStore(CalendarHelper.Current.EventStore);
            newEvent.StartDate = DateHelper.DateTimeToNSDate(vorstellung.Beginn ?? DateTime.Now);
            DateTime StartTime = vorstellung.Beginn ?? DateTime.MinValue;
            var Duration = vorstellung.Dauer ?? 90;
            newEvent.EndDate = DateHelper.DateTimeToNSDate(StartTime.AddMinutes(Duration));
            newEvent.Title = vorstellung.PublikationsTitelString;
            newEvent.Notes = vorstellung.ZeitUndOrtString;
            newEvent.Calendar = CalendarHelper.Current.EventStore.DefaultCalendarForNewEvents;

            CalendarHelper.Current.EventStore.SaveEvent(newEvent, EKSpan.ThisEvent, true, out error);

            if (error == null)
            {
                ViewModel.InsertCalendarID(vorstellung.Id, vorstellung.FilmId, newEvent.EventIdentifier);
            }
        }
        else
        {
            throw new Exception("Dieser Eintrag existiert bereits im Kalender.");
        }
    }

Do you have any idea ?

Sign In or Register to comment.