I am using the example found here : http://docs.xamarin.com/guides/ios/platform_features/introduction_to_eventkit#4.3.creating-an-event-programmatically
I asked Xamarin and they said I was supposed to use EventIdentifier
instead of CalendarItemIdentifier
- However, when you look up an event the way they say (startDate, endDate, and Calendar)
Calendar items don't have an EventIdentifier
property, and I'm not sure how to cast that or what I'm supposed to do there.
Here's a basic example of what I am doing. The problem is that when I go to look up an event by the identifier it doesn't exist since it's a CalendarItemIdentifier
instead of an EventIdentifier
public string CreateDefaultEvent ()
{
// Creating an event for demonstration purposes
// This is the sample code from your website to create an event programmatically
EKEvent newEvent = EKEvent.FromStore ( Application.AppEventStore );
// set the alarm for 10 minutes from now
newEvent.AddAlarm ( EKAlarm.FromDate ( DateTime.Now.AddMinutes ( 10 ) ) );
// make the event start 20 minutes from now and last 30 minutes
newEvent.StartDate = DateTime.Now.AddMinutes ( 20 );
newEvent.EndDate = DateTime.Now.AddMinutes ( 50 );
newEvent.Title = "Get outside and do some exercise!";
newEvent.Notes = "This is your motivational event to go and do 30 minutes of exercise. Super important. Do this.";
newEvent.Calendar = Application.AppEventStore.DefaultCalendarForNewEvents;
NSError e;
Application.AppEventStore.SaveEvent ( newEvent, EKSpan.ThisEvent, out e );
Console.WriteLine ("Event Saved, ID: " + newEvent.CalendarItemIdentifier);
return newEvent.CalendarItemIdentifier;
}
public string RetrieveCreatedEvent (string _eventIdentifier)
{
// We will just return the event's notes to see if we got a valid event
EKEvent savedEvent = Application.AppEventStore.EventFromIdentifier (_eventIdentifier);
return savedEvent.Notes;
}
Thanks in advance!