Skip to content

Interface to get the default calendar #49

@jorgenstorlie

Description

@jorgenstorlie

I want to get the default calendar, found s sample here:

https://github.com/xamarinhq/app-conference/blob/master/src/Conference.Clients.Portable/Services/ReminderService.cs

but this returned the first calendar with the user can modify.

Changed this:

static async Task GetOrCreateConferenceCalendarAsync()

Added:

				string DefaultCalendarIdentifier = "";

#if IOS
var _eventStore = new EKEventStore();
var ddd = _eventStore.DefaultCalendarForNewEvents;
if (ddd != null)
DefaultCalendarIdentifier = ddd.CalendarIdentifier;
#endif

				foreach (var calendar in calendars)
				{

					//find first calendar default
					if (calendar.ExternalID != DefaultCalendarIdentifier)
						continue;

					//find first calendar we can add stuff to
					if (!calendar.CanEditEvents)
						continue;

					ConferenceCalendarId = calendar.ExternalID;
					return calendar;
				}

This seems to work, but it would have been nice to have a interface that return the default calendar.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions