Scheduling Calendar Events with Swift

Set the “Privacy - Calendars Write Only Usage Description” (AKA NSCalendarsWriteOnlyAccessUsageDescription) key in Info.plist

Make sure that there is a default calendar the Settings app in the Calendar section (TODO screenshot)

Ask for access to the calendar

let store = EKEventStore()
store.requestWriteOnlyAccessToEvents { [weak self] success, error in
  // Handle success == false & error
}

Schedule Event and Alarm

guard let self else { return }
let alarm = EKAlarm(absoluteDate: wakeupTime)
let event = EKEvent(eventStore: store)
event.title = "Wake up!"
event.calendar = store.defaultCalendarForNewEvents
event.startDate = wakeupTime
event.endDate = wakeupTime
event.addAlarm(alarm)

try store.save(event, span: .thisEvent)

TODO Show geofence, etc. demonstrate what it will look like

TODO can we get a list of calendars? can we schedule in a specific calendar?