Drag and drop calendar item

Hello!


I have the flight tracking app and I want to integrate Drag and Drop so the user can drag the flight to Calendar app and create the event / reminder.


I've tried to use `public.calendar-event` as an identifier along with data string according to iCal format (VCALENDAR / VEVENT etc) but the standard Calendar app doesn't seem to accept it.

I've tried to drag the event from Calendar app and figured out that it declares the following providers:

"com.apple.eventkit.internal",

"com.apple.calendar.ics",

"com.apple.ical.ics",

"com.apple.uikit.useractivity",

"public.utf8-plain-text",

"public.utf16-plain-text"


Seems like

"com.apple.calendar.ics"

"com.apple.ical.ics"

exporting iCal formatted data with event details.


I've then tried to create NSItemProvider with there identifiers and drag-drop the data to Calendar but it doesn't seem to accept it.


Is it possible to drag-drop data to Calendar app in order to create event? If so, what UTI should be used and what data should be included in NSItemProvider.


Thanks in advance.

Any luck with this? Trying the same thing too... I have a Table View and I'm vending an Item provider array containing this:


NSItemProvider *itemProvider = [[NSItemProvider alloc] initWithItem:nil typeIdentifier:(NSString*)kUTTypeCalendarEvent];


Interesting to note... in the Simulator, if I create a Reminder in the Reminders app and then drag it into the Calendar app, the Calendar app crashes and on relaunch I see the Reminder was not added to the Calendar.

I've been playing around with Drag & Drop for a few days too and managed to figure this out.


  1. Make sure your custom object conforms to NSItemProviderWriting;
  2. The writableTypeIdentifiersForItemProvider array should contain the
    "com.apple.ical.ics"
    type identifier;
  3. Make a helper method to create a iCalendar vEvent string from your custom object;
  4. Return that string as utf8 encoded Data in the loadData(withTypeIdentifier: forItemProviderCompletionHandler:) function when
    "com.apple.ical.ics"
    is requested.


Checkout Session 227 from WWDC 2017 where they do something similar in creating a vCard string from a custom contact object.

I've also made a more detailed answer here, with a step-by-step of how to get it to work and additional resources.

I hope you find this helpful! 🙂

Drag and drop calendar item
 
 
Q