In this recipe, we will learn how create an event and save it to the device's calendar database.
Create a new Single View Application in Xamarin Studio and name it CalendarEventsApp
.
The app we will be creating will output the calendar events of the next 30 days. Make sure you have some calendar events in that period.
Let's create an event and save it to the device's calendar database by performing the following steps:
Add a button on the main view of the controller.
Add the
MonoTouch.EventKit
namespace in theCalendarEventAppViewController.cs
file.Enter the following code in the
ViewDidLoad
method:this.btnDisplayEvents.TouchUpInside += async (sender, e) => { EKAuthorizationStatus status = EKEventStore.GetAuthorizationStatus(EKEntityType.Event); EKEventStore evStore = new EKEventStore(); if (status == EKAuthorizationStatus.NotDetermined) { if (await evStore.RequestAccessAsync(EKEntityType.Event)) { this.DisplayEvents(evStore...