Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

EventKit - Where to store EKEventStore when using Forms

$
0
0

I want to be able to add and retrieve events to the native calendars of my Xamarin Forms app. I'm using the Dependency Service to run the platform specific code for changing calendar events.

I've read the 'Introduction to EventKit' and it creates a singleton version of EKEventStore when the app is started as it is an expensive operation to complete.

My problem is I'm not sure where to create and store EKEventStore in my forms app? App.cs is in my PCL and so doesn't want to know about iOS classes and I'm not using view controllers so can't create it in there either.

At the moment I have an EKEventStore property on the AppDelegate which I am accessing like this:

AppDelegate del = (AppDelegate)UIApplication.SharedApplication.Delegate;
del.Store.GetCalendarItem(identifier);

Is this the best way? It just seems messy to access and a bit too global. I was always encouraged to keep stuff out of the AppDelegate when I was writing native iOS apps so it kind of feels wrong. Am I missing something or should I just leave it in the AppDelegate?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>