EventKitInterface
public class EventKitInterface : EventKitInterfaceProtocol
Provides a basic mechanism for interacting with the EventKit
framework.
Conforms to the EventKitInterfaceProtocol
protocol.
Seealso
EventKitHandler
-
Initialize object with the
EKEventStore
and with a start and an end date.If the event store is not provided a new one is created. The start and the end date are used to filter events and reminders to remove.
Declaration
Swift
public init(eventSpan: EKSpan = .futureEvents, eventStartDate: Date = Date.yearAgo, eventEndDate: Date = Date.nextYear)
Parameters
eventStore
An event store used to communicate.
eventSpan
Indicates whether modifications should apply to a single event or all future events of a recurring event.
eventStartDate
A start date for items filtering. By default a year ago.
eventEndDate
An end date for items filtering. By default next year.
-
Adds all calendar items to the
EKEventStore
.Declaration
Swift
public func addAll(_ calendarItems: [EKCalendarItem], forType type: EKEntityType, completion: @escaping EventKitInterfaceProtocol.CompletionBlock = { _, _ in })
Parameters
calendarItems
List of calendar items, a subclasses of
EKCalendarItem
.type
Type of entity to add.
completion
Completion closure called after items were saved to the store.
-
Remove all calendar items from the
EKEventStore
.Declaration
Swift
public func removeAll(ofType type: EKEntityType, completion: @escaping EventKitInterfaceProtocol.CompletionBlock = { _, _ in })
-
Request access to the
EventKit
framework for given item type.Declaration
Swift
public func requestAccess(forType type: EKEntityType, completion: @escaping (Bool, Error?, EKEventStore?) -> Void)
Parameters
type
Type of entity to request access.
completion
Completion closure.
-
Checks if the application is authorized to use events or reminders.
Declaration
Swift
public static func authorized(forType type: EKEntityType) -> Bool
Parameters
type
The type of entity (events or reminders) to check.
Return Value
true
if the application was authorized,false
otherwise.