@ebarooni/capacitor-calendar 6.7.2 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EbarooniCapacitorCalendar.podspec +2 -2
- package/Package.swift +28 -0
- package/README.md +1197 -119
- package/android/build.gradle +8 -7
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +267 -317
- package/android/src/main/java/dev/barooni/capacitor/calendar/PluginError.kt +47 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt +348 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/CalendarEvent.kt +25 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/CalendarInfo.kt +14 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventGuest.kt +9 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/enums/CalendarPermissionScope.kt +15 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CheckPermissionInput.kt +20 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateCalendarInput.kt +18 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventInput.kt +27 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventWithPromptInput.kt +36 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteCalendarInput.kt +10 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventInput.kt +10 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventWithPromptInput.kt +14 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventsByIdInput.kt +11 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ListEventsInRangeInput.kt +14 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEvent.kt +25 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEventWithPromptInput.kt +37 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/OpenCalendarInput.kt +10 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/RequestAllPermissionsInput.kt +9 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/RequestPermissionInput.kt +40 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/CheckAllPermissionsResult.kt +17 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/CheckPermissionResult.kt +15 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/CreateCalendarResult.kt +21 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/CreateEventResult.kt +21 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/CreateEventWithPromptResult.kt +12 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/DeleteEventWithPromptResult.kt +14 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/DeleteEventsByIdResult.kt +27 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/GetDefaultCalendarResult.kt +34 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/ListCalendarsResult.kt +39 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/ListEventsInRangeResult.kt +58 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/ModifyEventWithPromptResult.kt +12 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/RequestAllPermissionsResult.kt +30 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/RequestPermissionResult.kt +42 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/templates/JSResult.kt +7 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/utils/ImplementationHelper.kt +387 -0
- package/dist/docs.json +3808 -1126
- package/dist/esm/definitions.d.ts +6 -759
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +40 -12
- package/dist/esm/index.js +11 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schemas/enums/attendee-role.d.ts +50 -0
- package/dist/esm/schemas/enums/attendee-role.js +52 -0
- package/dist/esm/schemas/enums/attendee-role.js.map +1 -0
- package/dist/esm/schemas/enums/attendee-status.d.ts +55 -0
- package/dist/esm/schemas/enums/attendee-status.js +57 -0
- package/dist/esm/schemas/enums/attendee-status.js.map +1 -0
- package/dist/esm/schemas/enums/attendee-type.d.ts +45 -0
- package/dist/esm/schemas/enums/attendee-type.js +47 -0
- package/dist/esm/schemas/enums/attendee-type.js.map +1 -0
- package/dist/esm/schemas/enums/calendar-chooser-display-style.d.ts +3 -6
- package/dist/esm/schemas/enums/calendar-chooser-display-style.js +3 -6
- package/dist/esm/schemas/enums/calendar-chooser-display-style.js.map +1 -1
- package/dist/esm/schemas/enums/calendar-permission-scope.d.ts +60 -0
- package/dist/esm/schemas/enums/calendar-permission-scope.js +62 -0
- package/dist/esm/schemas/enums/calendar-permission-scope.js.map +1 -0
- package/dist/esm/schemas/enums/calendar-source-type.d.ts +7 -16
- package/dist/esm/schemas/enums/calendar-source-type.js +7 -16
- package/dist/esm/schemas/enums/calendar-source-type.js.map +1 -1
- package/dist/esm/schemas/enums/calendar-type.d.ts +6 -9
- package/dist/esm/schemas/enums/calendar-type.js +6 -9
- package/dist/esm/schemas/enums/calendar-type.js.map +1 -1
- package/dist/esm/schemas/enums/event-availability.d.ts +30 -0
- package/dist/esm/schemas/enums/event-availability.js +32 -0
- package/dist/esm/schemas/enums/event-availability.js.map +1 -0
- package/dist/esm/schemas/enums/event-span.d.ts +3 -6
- package/dist/esm/schemas/enums/event-span.js +3 -6
- package/dist/esm/schemas/enums/event-span.js.map +1 -1
- package/dist/esm/schemas/enums/event-status.d.ts +26 -0
- package/dist/esm/schemas/enums/event-status.js +28 -0
- package/dist/esm/schemas/enums/event-status.js.map +1 -0
- package/dist/esm/schemas/enums/recurrence-frequency.d.ts +21 -0
- package/dist/esm/schemas/enums/recurrence-frequency.js +23 -0
- package/dist/esm/schemas/enums/recurrence-frequency.js.map +1 -0
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.d.ts +5 -8
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.js +5 -8
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar-event.d.ts +116 -48
- package/dist/esm/schemas/interfaces/calendar-event.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar-source.d.ts +10 -7
- package/dist/esm/schemas/interfaces/calendar-source.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar.d.ts +59 -25
- package/dist/esm/schemas/interfaces/calendar.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-calendar-options.d.ts +38 -0
- package/dist/esm/schemas/interfaces/create-calendar-options.js +2 -0
- package/dist/esm/schemas/interfaces/create-calendar-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-event-options.d.ts +96 -0
- package/dist/esm/schemas/interfaces/create-event-options.js +2 -0
- package/dist/esm/schemas/interfaces/create-event-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-event-with-prompt-options.d.ts +70 -0
- package/dist/esm/schemas/interfaces/create-event-with-prompt-options.js +2 -0
- package/dist/esm/schemas/interfaces/create-event-with-prompt-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-reminder-options.d.ts +54 -0
- package/dist/esm/schemas/interfaces/create-reminder-options.js +2 -0
- package/dist/esm/schemas/interfaces/create-reminder-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-calendar-options.d.ts +9 -0
- package/dist/esm/schemas/interfaces/delete-calendar-options.js +2 -0
- package/dist/esm/schemas/interfaces/delete-calendar-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-event-options.d.ts +18 -0
- package/dist/esm/schemas/interfaces/delete-event-options.js +2 -0
- package/dist/esm/schemas/interfaces/delete-event-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.d.ts +48 -0
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.js +2 -0
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-events-by-id-options.d.ts +18 -0
- package/dist/esm/schemas/interfaces/delete-events-by-id-options.js +2 -0
- package/dist/esm/schemas/interfaces/delete-events-by-id-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-reminder-options.d.ts +9 -0
- package/dist/esm/schemas/interfaces/delete-reminder-options.js +2 -0
- package/dist/esm/schemas/interfaces/delete-reminder-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-reminders-by-id-options.d.ts +9 -0
- package/dist/esm/schemas/interfaces/delete-reminders-by-id-options.js +2 -0
- package/dist/esm/schemas/interfaces/delete-reminders-by-id-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/event-guest.d.ts +13 -0
- package/dist/esm/schemas/interfaces/event-guest.js +2 -0
- package/dist/esm/schemas/interfaces/event-guest.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-reminder-by-id-options.d.ts +6 -0
- package/dist/esm/schemas/interfaces/get-reminder-by-id-options.js +2 -0
- package/dist/esm/schemas/interfaces/get-reminder-by-id-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-reminders-from-lists-options.d.ts +9 -0
- package/dist/esm/schemas/interfaces/get-reminders-from-lists-options.js +2 -0
- package/dist/esm/schemas/interfaces/get-reminders-from-lists-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-options.d.ts +17 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-options.js +2 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/modify-event-options.d.ts +103 -0
- package/dist/esm/schemas/interfaces/modify-event-options.js +2 -0
- package/dist/esm/schemas/interfaces/modify-event-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.d.ts +13 -0
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.js +2 -0
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/modify-reminder-options.d.ts +58 -0
- package/dist/esm/schemas/interfaces/modify-reminder-options.js +2 -0
- package/dist/esm/schemas/interfaces/modify-reminder-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/open-calendar-options.d.ts +10 -0
- package/dist/esm/schemas/interfaces/open-calendar-options.js +2 -0
- package/dist/esm/schemas/interfaces/open-calendar-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/recurrence-rule.d.ts +22 -0
- package/dist/esm/schemas/interfaces/recurrence-rule.js +2 -0
- package/dist/esm/schemas/interfaces/recurrence-rule.js.map +1 -0
- package/dist/esm/schemas/interfaces/reminder-recurrence-rule.d.ts +7 -25
- package/dist/esm/schemas/interfaces/reminder-recurrence-rule.js.map +1 -1
- package/dist/esm/schemas/interfaces/reminder.d.ts +29 -38
- package/dist/esm/schemas/interfaces/reminder.js.map +1 -1
- package/dist/esm/schemas/interfaces/reminders-list.d.ts +5 -3
- package/dist/esm/schemas/interfaces/reminders-list.js.map +1 -1
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-options.d.ts +18 -0
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-options.js +2 -0
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-options.js.map +1 -0
- package/dist/esm/schemas/types/event-edit-action.d.ts +4 -0
- package/dist/esm/schemas/types/event-edit-action.js +2 -0
- package/dist/esm/schemas/types/event-edit-action.js.map +1 -0
- package/dist/esm/sub-definitions/calendar-access.d.ts +114 -0
- package/dist/esm/sub-definitions/calendar-access.js +2 -0
- package/dist/esm/sub-definitions/calendar-access.js.map +1 -0
- package/dist/esm/sub-definitions/calendar-operations.d.ts +77 -0
- package/dist/esm/sub-definitions/calendar-operations.js +2 -0
- package/dist/esm/sub-definitions/calendar-operations.js.map +1 -0
- package/dist/esm/sub-definitions/event-operations.d.ts +111 -0
- package/dist/esm/sub-definitions/event-operations.js +2 -0
- package/dist/esm/sub-definitions/event-operations.js.map +1 -0
- package/dist/esm/sub-definitions/reminders-access.d.ts +22 -0
- package/dist/esm/sub-definitions/reminders-access.js +2 -0
- package/dist/esm/sub-definitions/reminders-access.js.map +1 -0
- package/dist/esm/sub-definitions/reminders-operations.d.ts +110 -0
- package/dist/esm/sub-definitions/reminders-operations.js +2 -0
- package/dist/esm/sub-definitions/reminders-operations.js.map +1 -0
- package/dist/esm/web.d.ts +86 -151
- package/dist/esm/web.js +67 -49
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +392 -172
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +392 -172
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapacitorCalendarPlugin/CapacitorCalendarPlugin.swift +348 -0
- package/ios/Sources/CapacitorCalendarPlugin/Implementation/CapacitorCalendar.swift +554 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Enums/CAPPermissionState.swift +6 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Enums/CalendarPermissionScope.swift +6 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Enums/EventEditAction.swift +20 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/CheckPermissionInput.swift +19 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/CreateCalendarInput.swift +32 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/CreateEventInput.swift +61 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/CreateEventWithPromptInput.swift +89 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/CreateReminderInput.swift +116 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/DeleteCalendarInput.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/DeleteEventInput.swift +27 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/DeleteEventWithPromptInput.swift +57 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/DeleteEventsByIdInput.swift +27 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/DeleteReminderInput.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/DeleteRemindersByIdInput.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/GetReminderByIdInput.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/GetRemindersFromListsInput.swift +24 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/ListEventsInRangeInput.swift +25 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/ModifyEventInput.swift +117 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/ModifyEventWithPromptInput.swift +83 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/ModifyReminderInput.swift +118 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/OpenCalendarInput.swift +17 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/RequestPermissionInput.swift +19 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/SelectCalendarsWithPromptInput.swift +32 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/CheckAllPermissionsResult.swift +15 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/CheckPermissionResult.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/CreateCalendarResult.swift +18 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/CreateEventResult.swift +18 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/CreateEventWithPromptResult.swift +15 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/CreateReminderResult.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/DeleteEventWithPromptResult.swift +15 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/DeleteEventsByIdResult.swift +23 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/DeleteRemindersByIdResult.swift +23 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/FetchAllCalendarSourcesResult.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/GetDefaultCalendarResult.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/GetReminderByIdResult.swift +20 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/GetRemindersFromListsResult.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/ListCalendarsResult.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/ListEventsInRangeResult.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/ModifyEventWithPromptResult.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/RequestAllPermissionsResult.swift +20 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/RequestPermissionResult.swift +15 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/SelectCalendarsWithPromptResult.swift +16 -0
- package/ios/Sources/CapacitorCalendarPlugin/Models/Templates/JSResult.swift +5 -0
- package/ios/Sources/CapacitorCalendarPlugin/PluginConfig.swift +42 -0
- package/ios/Sources/CapacitorCalendarPlugin/PluginError.swift +87 -0
- package/ios/Sources/CapacitorCalendarPlugin/Utils/ImplementationHelper.swift +361 -0
- package/ios/Sources/CapacitorCalendarPlugin/Utils/UIColorFromHexExtension.swift +32 -0
- package/ios/Tests/CapacitorCalendarPluginTests/CapacitorCalendarPluginTests.swift +15 -0
- package/package.json +68 -72
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendar.kt +0 -358
- package/assets/images/text-logo.png +0 -0
- package/dist/esm/schemas/enums/calendar-chooser-selection-style.d.ts +0 -16
- package/dist/esm/schemas/enums/calendar-chooser-selection-style.js +0 -18
- package/dist/esm/schemas/enums/calendar-chooser-selection-style.js.map +0 -1
- package/dist/esm/schemas/enums/plugin-permission.d.ts +0 -58
- package/dist/esm/schemas/enums/plugin-permission.js +0 -60
- package/dist/esm/schemas/enums/plugin-permission.js.map +0 -1
- package/dist/esm/schemas/interfaces/plugin-permissions-map.d.ts +0 -4
- package/dist/esm/schemas/interfaces/plugin-permissions-map.js +0 -2
- package/dist/esm/schemas/interfaces/plugin-permissions-map.js.map +0 -1
- package/ios/Plugin/CapacitorCalendar.swift +0 -635
- package/ios/Plugin/CapacitorCalendarPlugin.h +0 -10
- package/ios/Plugin/CapacitorCalendarPlugin.m +0 -36
- package/ios/Plugin/CapacitorCalendarPlugin.swift +0 -648
- package/ios/Plugin/CapacitorCalendarPluginError.swift +0 -22
- package/ios/Plugin/CapacitorReminders.swift +0 -456
- package/ios/Plugin/EventCreationParameters.swift +0 -22
- package/ios/Plugin/EventDeleteResults.swift +0 -14
- package/ios/Plugin/Info.plist +0 -24
- package/ios/Plugin/PermissionState.swift +0 -16
- package/ios/Plugin/RecurrenceParameters.swift +0 -15
- package/ios/Plugin/ReminderCreationParameters.swift +0 -23
- package/ios/Plugin/UIColorExtensions.swift +0 -28
- /package/{LICENSE.txt → LICENSE} +0 -0
|
@@ -1,635 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import Capacitor
|
|
3
|
-
import EventKitUI
|
|
4
|
-
|
|
5
|
-
public class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarChooserDelegate {
|
|
6
|
-
private let bridge: (any CAPBridgeProtocol)?
|
|
7
|
-
private let eventStore: EKEventStore
|
|
8
|
-
private var currentCreateEventContinuation: CheckedContinuation<[String], any Error>?
|
|
9
|
-
private var currentSelectCalendarsContinuation: CheckedContinuation<[[String: Any]], any Error>?
|
|
10
|
-
|
|
11
|
-
init(bridge: (any CAPBridgeProtocol)?, eventStore: EKEventStore) {
|
|
12
|
-
self.bridge = bridge
|
|
13
|
-
self.eventStore = eventStore
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public func createEventWithPrompt(with parameters: EventCreationParameters) async throws -> [String] {
|
|
17
|
-
let newEvent = EKEvent(eventStore: eventStore)
|
|
18
|
-
if let calendarId = parameters.calendarId, let calendar = eventStore.calendar(withIdentifier: calendarId) {
|
|
19
|
-
newEvent.calendar = calendar
|
|
20
|
-
} else {
|
|
21
|
-
newEvent.calendar = eventStore.defaultCalendarForNewEvents
|
|
22
|
-
}
|
|
23
|
-
newEvent.title = parameters.title
|
|
24
|
-
if let location = parameters.location {
|
|
25
|
-
newEvent.location = location
|
|
26
|
-
}
|
|
27
|
-
if let startDate = parameters.startDate {
|
|
28
|
-
newEvent.startDate = Date(timeIntervalSince1970: startDate / 1000)
|
|
29
|
-
}
|
|
30
|
-
if let endDate = parameters.endDate {
|
|
31
|
-
newEvent.endDate = Date(timeIntervalSince1970: endDate / 1000)
|
|
32
|
-
}
|
|
33
|
-
if let isAllDay = parameters.isAllDay {
|
|
34
|
-
newEvent.isAllDay = isAllDay
|
|
35
|
-
}
|
|
36
|
-
if let alertOffsetInMinutesSingle = parameters.alertOffsetInMinutesSingle, alertOffsetInMinutesSingle >= 0 {
|
|
37
|
-
newEvent.addAlarm(EKAlarm(relativeOffset: TimeInterval(-alertOffsetInMinutesSingle * 60)))
|
|
38
|
-
} else if let alertOffsetInMinutesMultiple = parameters.alertOffsetInMinutesMultiple {
|
|
39
|
-
for alert in alertOffsetInMinutesMultiple {
|
|
40
|
-
if alert >= 0 {
|
|
41
|
-
newEvent.addAlarm(EKAlarm(relativeOffset: TimeInterval(-alert * 60)))
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if let notes = parameters.notes {
|
|
46
|
-
newEvent.notes = notes
|
|
47
|
-
}
|
|
48
|
-
if let urlString = parameters.url, let url = URL(string: urlString) {
|
|
49
|
-
newEvent.url = url
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return try await withCheckedThrowingContinuation { continuation in
|
|
53
|
-
guard let viewController = bridge?.viewController else {
|
|
54
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.viewControllerUnavailable)
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
Task { @MainActor in
|
|
59
|
-
let eventEditViewController = EKEventEditViewController()
|
|
60
|
-
eventEditViewController.event = newEvent
|
|
61
|
-
eventEditViewController.eventStore = eventStore
|
|
62
|
-
eventEditViewController.editViewDelegate = self
|
|
63
|
-
currentCreateEventContinuation = continuation
|
|
64
|
-
viewController.present(eventEditViewController, animated: true, completion: nil)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public func modifyEventWithPrompt(id: String, update: EventCreationParameters? = nil) async throws -> [String] {
|
|
70
|
-
return try await withCheckedThrowingContinuation { continuation in
|
|
71
|
-
guard let viewController = bridge?.viewController else {
|
|
72
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.viewControllerUnavailable)
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
guard let event = eventStore.event(withIdentifier: id) else {
|
|
77
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.undefinedEvent)
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if update != nil {
|
|
82
|
-
if (update?.title) != nil {
|
|
83
|
-
event.title = update?.title
|
|
84
|
-
}
|
|
85
|
-
if let calendarId = update?.calendarId, let calendar = eventStore.calendar(withIdentifier: calendarId) {
|
|
86
|
-
event.calendar = calendar
|
|
87
|
-
}
|
|
88
|
-
if update?.location != nil {
|
|
89
|
-
event.location = update?.location
|
|
90
|
-
}
|
|
91
|
-
if let startDate = update?.startDate {
|
|
92
|
-
event.startDate = Date(timeIntervalSince1970: startDate / 1000)
|
|
93
|
-
}
|
|
94
|
-
if let endDate = update?.endDate {
|
|
95
|
-
event.endDate = Date(timeIntervalSince1970: endDate / 1000)
|
|
96
|
-
}
|
|
97
|
-
if let isAllDay = update?.isAllDay {
|
|
98
|
-
event.isAllDay = isAllDay
|
|
99
|
-
}
|
|
100
|
-
if let notes = update?.notes {
|
|
101
|
-
event.notes = notes
|
|
102
|
-
}
|
|
103
|
-
if let urlString = update?.url, let url = URL(string: urlString) {
|
|
104
|
-
event.url = url
|
|
105
|
-
}
|
|
106
|
-
if let alertOffsetInMinutesSingle = update?.alertOffsetInMinutesSingle, alertOffsetInMinutesSingle >= 0 {
|
|
107
|
-
if event.hasAlarms {
|
|
108
|
-
for alarm in event.alarms! {
|
|
109
|
-
event.removeAlarm(alarm)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
event.addAlarm(EKAlarm(relativeOffset: TimeInterval(-alertOffsetInMinutesSingle * 60)))
|
|
113
|
-
} else if let alertOffsetInMinutesMultiple = update?.alertOffsetInMinutesMultiple {
|
|
114
|
-
if event.hasAlarms {
|
|
115
|
-
for alarm in event.alarms! {
|
|
116
|
-
event.removeAlarm(alarm)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
for alert in alertOffsetInMinutesMultiple {
|
|
120
|
-
if alert >= 0 {
|
|
121
|
-
event.addAlarm(EKAlarm(relativeOffset: TimeInterval(-alert * 60)))
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
Task { @MainActor in
|
|
128
|
-
let eventEditViewController = EKEventEditViewController()
|
|
129
|
-
eventEditViewController.event = event
|
|
130
|
-
eventEditViewController.eventStore = eventStore
|
|
131
|
-
eventEditViewController.editViewDelegate = self
|
|
132
|
-
currentCreateEventContinuation = continuation
|
|
133
|
-
viewController.present(eventEditViewController, animated: true, completion: nil)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
public func modifyEvent(id: String, span: EKSpan, update: EventCreationParameters) throws {
|
|
139
|
-
guard let event = eventStore.event(withIdentifier: id) else {
|
|
140
|
-
throw CapacitorCalendarPluginError.undefinedEvent
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (update.title) != nil {
|
|
144
|
-
event.title = update.title
|
|
145
|
-
}
|
|
146
|
-
if let calendarId = update.calendarId, let calendar = eventStore.calendar(withIdentifier: calendarId) {
|
|
147
|
-
event.calendar = calendar
|
|
148
|
-
}
|
|
149
|
-
if update.location != nil {
|
|
150
|
-
event.location = update.location
|
|
151
|
-
}
|
|
152
|
-
if let startDate = update.startDate {
|
|
153
|
-
event.startDate = Date(timeIntervalSince1970: startDate / 1000)
|
|
154
|
-
}
|
|
155
|
-
if let endDate = update.endDate {
|
|
156
|
-
event.endDate = Date(timeIntervalSince1970: endDate / 1000)
|
|
157
|
-
}
|
|
158
|
-
if let isAllDay = update.isAllDay {
|
|
159
|
-
event.isAllDay = isAllDay
|
|
160
|
-
}
|
|
161
|
-
if let notes = update.notes {
|
|
162
|
-
event.notes = notes
|
|
163
|
-
}
|
|
164
|
-
if let urlString = update.url, let url = URL(string: urlString) {
|
|
165
|
-
event.url = url
|
|
166
|
-
}
|
|
167
|
-
if let alertOffsetInMinutesSingle = update.alertOffsetInMinutesSingle, alertOffsetInMinutesSingle >= 0 {
|
|
168
|
-
if event.hasAlarms {
|
|
169
|
-
for alarm in event.alarms! {
|
|
170
|
-
event.removeAlarm(alarm)
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
event.addAlarm(EKAlarm(relativeOffset: TimeInterval(-alertOffsetInMinutesSingle * 60)))
|
|
174
|
-
} else if let alertOffsetInMinutesMultiple = update.alertOffsetInMinutesMultiple {
|
|
175
|
-
if event.hasAlarms {
|
|
176
|
-
for alarm in event.alarms! {
|
|
177
|
-
event.removeAlarm(alarm)
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
for alert in alertOffsetInMinutesMultiple {
|
|
181
|
-
if alert >= 0 {
|
|
182
|
-
event.addAlarm(EKAlarm(relativeOffset: TimeInterval(-alert * 60)))
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
do {
|
|
188
|
-
try eventStore.save(event, span: span)
|
|
189
|
-
} catch {
|
|
190
|
-
throw CapacitorCalendarPluginError.undefinedEvent
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
public func selectCalendarsWithPrompt(selectionStyle: Int, displayStyle: Int) async throws -> [[String: Any]] {
|
|
195
|
-
return try await withCheckedThrowingContinuation { continuation in
|
|
196
|
-
guard let viewController = bridge?.viewController else {
|
|
197
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.viewControllerUnavailable)
|
|
198
|
-
return
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
Task { @MainActor in
|
|
202
|
-
if let selectionStyle = EKCalendarChooserSelectionStyle(rawValue: selectionStyle),
|
|
203
|
-
let displayStyle = EKCalendarChooserDisplayStyle(rawValue: displayStyle) {
|
|
204
|
-
let calendarChooser = EKCalendarChooser(
|
|
205
|
-
selectionStyle: selectionStyle,
|
|
206
|
-
displayStyle: displayStyle,
|
|
207
|
-
eventStore: eventStore
|
|
208
|
-
)
|
|
209
|
-
calendarChooser.showsDoneButton = true
|
|
210
|
-
calendarChooser.showsCancelButton = true
|
|
211
|
-
calendarChooser.delegate = self
|
|
212
|
-
currentSelectCalendarsContinuation = continuation
|
|
213
|
-
viewController.present(
|
|
214
|
-
UINavigationController(rootViewController: calendarChooser),
|
|
215
|
-
animated: true,
|
|
216
|
-
completion: nil
|
|
217
|
-
)
|
|
218
|
-
} else {
|
|
219
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.viewControllerUnavailable)
|
|
220
|
-
return
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
public func listCalendars() -> [[String: Any]] {
|
|
227
|
-
return convertEKCalendarsToDictionaries(calendars: Set(eventStore.calendars(for: .event)))
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
public func getDefaultCalendar() throws -> [String: Any]? {
|
|
231
|
-
let defaultCalendar = eventStore.defaultCalendarForNewEvents
|
|
232
|
-
if let defaultCalendar = defaultCalendar {
|
|
233
|
-
var calendarDict: [String: Any] = [
|
|
234
|
-
"id": defaultCalendar.calendarIdentifier,
|
|
235
|
-
"title": defaultCalendar.title,
|
|
236
|
-
"color": hexStringFromColor(color: defaultCalendar.cgColor),
|
|
237
|
-
"isImmutable": defaultCalendar.isImmutable,
|
|
238
|
-
"allowsContentModifications": defaultCalendar.allowsContentModifications,
|
|
239
|
-
"type": defaultCalendar.type.rawValue,
|
|
240
|
-
"isSubscribed": defaultCalendar.isSubscribed
|
|
241
|
-
]
|
|
242
|
-
if let calendarSource = defaultCalendar.source {
|
|
243
|
-
calendarDict["source"] = [
|
|
244
|
-
"type": calendarSource.sourceType.rawValue,
|
|
245
|
-
"id": calendarSource.sourceIdentifier,
|
|
246
|
-
"title": calendarSource.title
|
|
247
|
-
]
|
|
248
|
-
}
|
|
249
|
-
return calendarDict
|
|
250
|
-
} else {
|
|
251
|
-
return nil
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
public func createEvent(with parameters: EventCreationParameters) throws -> String {
|
|
256
|
-
let fallbackStartDate = Date()
|
|
257
|
-
let newEvent = EKEvent(eventStore: eventStore)
|
|
258
|
-
if let calendarId = parameters.calendarId, let calendar = eventStore.calendar(withIdentifier: calendarId) {
|
|
259
|
-
newEvent.calendar = calendar
|
|
260
|
-
} else {
|
|
261
|
-
newEvent.calendar = eventStore.defaultCalendarForNewEvents
|
|
262
|
-
}
|
|
263
|
-
newEvent.title = parameters.title
|
|
264
|
-
if let location = parameters.location {
|
|
265
|
-
newEvent.location = location
|
|
266
|
-
}
|
|
267
|
-
if let startDate = parameters.startDate {
|
|
268
|
-
newEvent.startDate = Date(timeIntervalSince1970: startDate / 1000)
|
|
269
|
-
} else {
|
|
270
|
-
newEvent.startDate = fallbackStartDate
|
|
271
|
-
}
|
|
272
|
-
if let endDate = parameters.endDate {
|
|
273
|
-
newEvent.endDate = Date(timeIntervalSince1970: endDate / 1000)
|
|
274
|
-
} else {
|
|
275
|
-
newEvent.endDate = fallbackStartDate.addingTimeInterval(3600)
|
|
276
|
-
}
|
|
277
|
-
if let isAllDay = parameters.isAllDay {
|
|
278
|
-
newEvent.isAllDay = isAllDay
|
|
279
|
-
}
|
|
280
|
-
if let alertOffsetInMinutesSingle = parameters.alertOffsetInMinutesSingle, alertOffsetInMinutesSingle >= 0 {
|
|
281
|
-
newEvent.addAlarm(EKAlarm(relativeOffset: TimeInterval(-alertOffsetInMinutesSingle * 60)))
|
|
282
|
-
} else if let alertOffsetInMinutesMultiple = parameters.alertOffsetInMinutesMultiple {
|
|
283
|
-
for alert in alertOffsetInMinutesMultiple {
|
|
284
|
-
if alert >= 0 {
|
|
285
|
-
newEvent.addAlarm(EKAlarm(relativeOffset: TimeInterval(-alert * 60)))
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
if let notes = parameters.notes {
|
|
290
|
-
newEvent.notes = notes
|
|
291
|
-
}
|
|
292
|
-
if let urlString = parameters.url, let url = URL(string: urlString) {
|
|
293
|
-
newEvent.url = url
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
do {
|
|
297
|
-
try eventStore.save(newEvent, span: .thisEvent)
|
|
298
|
-
return newEvent.eventIdentifier
|
|
299
|
-
} catch {
|
|
300
|
-
throw CapacitorCalendarPluginError.undefinedEvent
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
public func checkAllPermissions() async throws -> [String: String] {
|
|
305
|
-
return try await withCheckedThrowingContinuation { continuation in
|
|
306
|
-
var permissionsState: [String: String]
|
|
307
|
-
switch EKEventStore.authorizationStatus(for: .event) {
|
|
308
|
-
case .authorized, .fullAccess:
|
|
309
|
-
permissionsState = [
|
|
310
|
-
"readCalendar": PermissionState.granted.rawValue,
|
|
311
|
-
"writeCalendar": PermissionState.granted.rawValue
|
|
312
|
-
]
|
|
313
|
-
case .denied, .restricted:
|
|
314
|
-
permissionsState = [
|
|
315
|
-
"readCalendar": PermissionState.denied.rawValue,
|
|
316
|
-
"writeCalendar": PermissionState.denied.rawValue
|
|
317
|
-
]
|
|
318
|
-
case .writeOnly:
|
|
319
|
-
permissionsState = [
|
|
320
|
-
"readCalendar": PermissionState.prompt.rawValue,
|
|
321
|
-
"writeCalendar": PermissionState.granted.rawValue
|
|
322
|
-
]
|
|
323
|
-
case .notDetermined:
|
|
324
|
-
permissionsState = [
|
|
325
|
-
"readCalendar": PermissionState.prompt.rawValue,
|
|
326
|
-
"writeCalendar": PermissionState.prompt.rawValue
|
|
327
|
-
]
|
|
328
|
-
@unknown default:
|
|
329
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.unknownPermissionStatus)
|
|
330
|
-
return
|
|
331
|
-
}
|
|
332
|
-
continuation.resume(returning: permissionsState)
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
public func requestWriteAccessToEvents() async throws -> [String: String] {
|
|
337
|
-
return try await withCheckedThrowingContinuation { continuation in
|
|
338
|
-
if #available(iOS 17.0, *) {
|
|
339
|
-
eventStore.requestWriteOnlyAccessToEvents { granted, error in
|
|
340
|
-
if let error = error {
|
|
341
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.eventStoreAuthorization)
|
|
342
|
-
return
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
var permissionState: String
|
|
346
|
-
if granted {
|
|
347
|
-
permissionState = PermissionState.granted.rawValue
|
|
348
|
-
} else {
|
|
349
|
-
permissionState = PermissionState.denied.rawValue
|
|
350
|
-
}
|
|
351
|
-
continuation.resume(returning: ["result": permissionState])
|
|
352
|
-
}
|
|
353
|
-
} else {
|
|
354
|
-
eventStore.requestAccess(to: .event) { granted, error in
|
|
355
|
-
if let error = error {
|
|
356
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.eventStoreAuthorization)
|
|
357
|
-
return
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
var permissionState: String
|
|
361
|
-
if granted {
|
|
362
|
-
permissionState = PermissionState.granted.rawValue
|
|
363
|
-
} else {
|
|
364
|
-
permissionState = PermissionState.denied.rawValue
|
|
365
|
-
}
|
|
366
|
-
continuation.resume(returning: ["result": permissionState])
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
public func requestFullAccessToEvents() async throws -> String {
|
|
373
|
-
return try await withCheckedThrowingContinuation { continuation in
|
|
374
|
-
if #available(iOS 17.0, *) {
|
|
375
|
-
eventStore.requestFullAccessToEvents { granted, error in
|
|
376
|
-
if let error = error {
|
|
377
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.eventStoreAuthorization)
|
|
378
|
-
return
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
var permissionState: String
|
|
382
|
-
if granted {
|
|
383
|
-
permissionState = PermissionState.granted.rawValue
|
|
384
|
-
} else {
|
|
385
|
-
permissionState = PermissionState.denied.rawValue
|
|
386
|
-
}
|
|
387
|
-
continuation.resume(returning: permissionState)
|
|
388
|
-
}
|
|
389
|
-
} else {
|
|
390
|
-
eventStore.requestAccess(to: .event) { granted, error in
|
|
391
|
-
if let error = error {
|
|
392
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.eventStoreAuthorization)
|
|
393
|
-
return
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
var permissionState: String
|
|
397
|
-
if granted {
|
|
398
|
-
permissionState = PermissionState.granted.rawValue
|
|
399
|
-
} else {
|
|
400
|
-
permissionState = PermissionState.denied.rawValue
|
|
401
|
-
}
|
|
402
|
-
continuation.resume(returning: permissionState)
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
public func openCalendar(date: Double) async throws {
|
|
409
|
-
return try await withCheckedThrowingContinuation { continuation in
|
|
410
|
-
guard let url = URL(string: "calshow:\(date)") else {
|
|
411
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.unableToOpenCalendar)
|
|
412
|
-
return
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
Task { @MainActor in
|
|
416
|
-
guard UIApplication.shared.canOpenURL(url) else {
|
|
417
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.unableToOpenCalendar)
|
|
418
|
-
return
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
UIApplication.shared.open(url, options: [:]) { success in
|
|
422
|
-
if success {
|
|
423
|
-
continuation.resume()
|
|
424
|
-
} else {
|
|
425
|
-
continuation.resume(throwing: CapacitorCalendarPluginError.unableToOpenCalendar)
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
public func listEventsInRange(
|
|
433
|
-
startDate: Double,
|
|
434
|
-
endDate: Double
|
|
435
|
-
) throws -> [[String: Any]] {
|
|
436
|
-
let predicate = eventStore.predicateForEvents(
|
|
437
|
-
withStart: Date(timeIntervalSince1970: startDate / 1000),
|
|
438
|
-
end: Date(timeIntervalSince1970: endDate / 1000), calendars: nil
|
|
439
|
-
)
|
|
440
|
-
let events = self.eventStore.events(matching: predicate)
|
|
441
|
-
return dictionaryRepresentationOfEvents(events: events)
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
public func deleteEventsById(ids: JSArray) async throws -> EventDeleteResults {
|
|
445
|
-
await withCheckedContinuation { continuation in
|
|
446
|
-
|
|
447
|
-
var deletedEvents: [String] = []
|
|
448
|
-
var failedToDeleteEvents: [String] = []
|
|
449
|
-
|
|
450
|
-
for id in ids {
|
|
451
|
-
guard let event = eventStore.event(withIdentifier: "\(id)") else {
|
|
452
|
-
failedToDeleteEvents.append("\(id)")
|
|
453
|
-
continue
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
do {
|
|
457
|
-
try eventStore.remove(event, span: .thisEvent, commit: false)
|
|
458
|
-
deletedEvents.append("\(id)")
|
|
459
|
-
} catch {
|
|
460
|
-
failedToDeleteEvents.append("\(id)")
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
do {
|
|
465
|
-
try eventStore.commit()
|
|
466
|
-
} catch {
|
|
467
|
-
failedToDeleteEvents.append(contentsOf: deletedEvents)
|
|
468
|
-
deletedEvents.removeAll()
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
continuation.resume(returning: EventDeleteResults(deleted: deletedEvents, failed: failedToDeleteEvents))
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
public func createCalendar(title: String, color: String?, sourceId: String?) throws -> String {
|
|
476
|
-
let newCalendar = EKCalendar(for: .event, eventStore: eventStore)
|
|
477
|
-
newCalendar.title = title
|
|
478
|
-
if let calendarColor = color {
|
|
479
|
-
newCalendar.cgColor = UIColor(hex: calendarColor)?.cgColor
|
|
480
|
-
} else {
|
|
481
|
-
newCalendar.cgColor = eventStore.defaultCalendarForNewEvents?.cgColor
|
|
482
|
-
}
|
|
483
|
-
if let calendarSourceId = sourceId {
|
|
484
|
-
let matchingSource = eventStore.sources.first(where: { $0.sourceIdentifier == calendarSourceId })
|
|
485
|
-
if let requestedSource = matchingSource {
|
|
486
|
-
newCalendar.source = requestedSource
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
} else {
|
|
490
|
-
newCalendar.source = eventStore.defaultCalendarForNewEvents?.source
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
do {
|
|
494
|
-
try eventStore.saveCalendar(newCalendar, commit: true)
|
|
495
|
-
} catch {
|
|
496
|
-
throw CapacitorCalendarPluginError.unableToCreateCalendar
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
return newCalendar.calendarIdentifier
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
public func deleteCalendar(id: String) throws {
|
|
503
|
-
if let calendar = eventStore.calendar(withIdentifier: id) {
|
|
504
|
-
try eventStore.removeCalendar(calendar, commit: true)
|
|
505
|
-
} else {
|
|
506
|
-
throw CapacitorCalendarPluginError.calendarNotFound
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
public func eventEditViewController(
|
|
511
|
-
_ controller: EKEventEditViewController,
|
|
512
|
-
didCompleteWith action: EKEventEditViewAction
|
|
513
|
-
) {
|
|
514
|
-
controller.dismiss(animated: true) {
|
|
515
|
-
if action == .saved {
|
|
516
|
-
if let event = controller.event, let eventId = event.eventIdentifier {
|
|
517
|
-
self.currentCreateEventContinuation?.resume(returning: [eventId])
|
|
518
|
-
} else {
|
|
519
|
-
self.currentCreateEventContinuation?.resume(throwing: CapacitorCalendarPluginError.undefinedEvent)
|
|
520
|
-
return
|
|
521
|
-
}
|
|
522
|
-
} else if action == .canceled {
|
|
523
|
-
self.currentCreateEventContinuation?.resume(returning: [])
|
|
524
|
-
} else {
|
|
525
|
-
self.currentCreateEventContinuation?.resume(throwing: CapacitorCalendarPluginError.unknownActionEventCreationPrompt)
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
public func calendarChooserDidFinish(_ calendarChooser: EKCalendarChooser) {
|
|
531
|
-
let selectedCalendars = convertEKCalendarsToDictionaries(calendars: calendarChooser.selectedCalendars)
|
|
532
|
-
bridge?.viewController?.dismiss(animated: true) {
|
|
533
|
-
self.currentSelectCalendarsContinuation?.resume(returning: selectedCalendars)
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
public func calendarChooserDidCancel(_ calendarChooser: EKCalendarChooser) {
|
|
538
|
-
bridge?.viewController?.dismiss(animated: true) {
|
|
539
|
-
self.currentSelectCalendarsContinuation?.resume(returning: [])
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
public func fetchAllCalendarSources() throws -> [[String: Any]] {
|
|
544
|
-
var result: [[String: Any]] = []
|
|
545
|
-
|
|
546
|
-
for source in eventStore.sources {
|
|
547
|
-
let sourceDict: [String: Any] = [
|
|
548
|
-
"id": source.sourceIdentifier,
|
|
549
|
-
"title": source.title,
|
|
550
|
-
"type": source.sourceType.rawValue
|
|
551
|
-
]
|
|
552
|
-
result.append(sourceDict)
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
return result
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
private func convertEKCalendarsToDictionaries(calendars: Set<EKCalendar>) -> [[String: Any]] {
|
|
559
|
-
var result: [[String: Any]] = []
|
|
560
|
-
|
|
561
|
-
for calendar in calendars {
|
|
562
|
-
var calendarDict: [String: Any] = [
|
|
563
|
-
"id": calendar.calendarIdentifier,
|
|
564
|
-
"title": calendar.title,
|
|
565
|
-
"color": hexStringFromColor(color: calendar.cgColor),
|
|
566
|
-
"isImmutable": calendar.isImmutable,
|
|
567
|
-
"allowsContentModifications": calendar.allowsContentModifications,
|
|
568
|
-
"type": calendar.type.rawValue,
|
|
569
|
-
"isSubscribed": calendar.isSubscribed
|
|
570
|
-
]
|
|
571
|
-
if let calendarSource = calendar.source {
|
|
572
|
-
calendarDict["source"] = [
|
|
573
|
-
"type": calendarSource.sourceType.rawValue,
|
|
574
|
-
"id": calendarSource.sourceIdentifier,
|
|
575
|
-
"title": calendarSource.title
|
|
576
|
-
]
|
|
577
|
-
}
|
|
578
|
-
result.append(calendarDict)
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
return result
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
private func dictionaryRepresentationOfEvents(events: [EKEvent]) -> [[String: Any]] {
|
|
585
|
-
return events.map { event in
|
|
586
|
-
var dict = [String: Any]()
|
|
587
|
-
dict["id"] = event.eventIdentifier
|
|
588
|
-
if let title = event.title, !title.isEmpty {
|
|
589
|
-
dict["title"] = title
|
|
590
|
-
}
|
|
591
|
-
if let location = event.location, !location.isEmpty {
|
|
592
|
-
dict["location"] = location
|
|
593
|
-
}
|
|
594
|
-
if let organizer = event.organizer?.name, !organizer.isEmpty {
|
|
595
|
-
dict["organizer"] = organizer
|
|
596
|
-
}
|
|
597
|
-
if let notes = event.notes, !notes.isEmpty {
|
|
598
|
-
dict["description"] = notes
|
|
599
|
-
}
|
|
600
|
-
if let startDate = event.startDate {
|
|
601
|
-
dict["startDate"] = startDate.timeIntervalSince1970 * 1000
|
|
602
|
-
}
|
|
603
|
-
if let endDate = event.endDate {
|
|
604
|
-
dict["endDate"] = endDate.timeIntervalSince1970 * 1000
|
|
605
|
-
}
|
|
606
|
-
if let timezone = event.timeZone, let region = event.timeZone?.identifier, let abbreviation = timezone.abbreviation() {
|
|
607
|
-
dict["eventTimezone"] = ["region": region, "abbreviation": abbreviation]
|
|
608
|
-
dict["eventEndTimezone"] = ["region": region, "abbreviation": abbreviation]
|
|
609
|
-
}
|
|
610
|
-
if let color = event.calendar.cgColor {
|
|
611
|
-
dict["eventColor"] = hexStringFromColor(color: color)
|
|
612
|
-
}
|
|
613
|
-
if let url = event.url {
|
|
614
|
-
dict["url"] = url.absoluteString
|
|
615
|
-
}
|
|
616
|
-
dict["isAllDay"] = event.isAllDay
|
|
617
|
-
dict["calendarId"] = event.calendar.calendarIdentifier
|
|
618
|
-
return dict
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
private func hexStringFromColor(color: CGColor) -> String {
|
|
623
|
-
guard let components = color.components, components.count >= 3 else {
|
|
624
|
-
return "#000000"
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
let red = Float(components[0])
|
|
628
|
-
let green = Float(components[1])
|
|
629
|
-
let blue = Float(components[2])
|
|
630
|
-
return String(format: "#%02lX%02lX%02lX",
|
|
631
|
-
lroundf(red * 255),
|
|
632
|
-
lroundf(green * 255),
|
|
633
|
-
lroundf(blue * 255))
|
|
634
|
-
}
|
|
635
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#import <UIKit/UIKit.h>
|
|
2
|
-
|
|
3
|
-
//! Project version number for Plugin.
|
|
4
|
-
FOUNDATION_EXPORT double PluginVersionNumber;
|
|
5
|
-
|
|
6
|
-
//! Project version string for Plugin.
|
|
7
|
-
FOUNDATION_EXPORT const unsigned char PluginVersionString[];
|
|
8
|
-
|
|
9
|
-
// In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
|
|
10
|
-
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#import <Foundation/Foundation.h>
|
|
2
|
-
#import <Capacitor/Capacitor.h>
|
|
3
|
-
|
|
4
|
-
// Define the plugin using the CAP_PLUGIN Macro, and
|
|
5
|
-
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
-
CAP_PLUGIN(CapacitorCalendarPlugin, "CapacitorCalendar",
|
|
7
|
-
CAP_PLUGIN_METHOD(createEventWithPrompt, CAPPluginReturnPromise);
|
|
8
|
-
CAP_PLUGIN_METHOD(checkPermission, CAPPluginReturnPromise);
|
|
9
|
-
CAP_PLUGIN_METHOD(checkAllPermissions, CAPPluginReturnPromise);
|
|
10
|
-
CAP_PLUGIN_METHOD(requestPermission, CAPPluginReturnPromise);
|
|
11
|
-
CAP_PLUGIN_METHOD(requestAllPermissions, CAPPluginReturnPromise);
|
|
12
|
-
CAP_PLUGIN_METHOD(selectCalendarsWithPrompt, CAPPluginReturnPromise);
|
|
13
|
-
CAP_PLUGIN_METHOD(listCalendars, CAPPluginReturnPromise);
|
|
14
|
-
CAP_PLUGIN_METHOD(getDefaultCalendar, CAPPluginReturnPromise);
|
|
15
|
-
CAP_PLUGIN_METHOD(createEvent, CAPPluginReturnPromise);
|
|
16
|
-
CAP_PLUGIN_METHOD(getDefaultRemindersList, CAPPluginReturnPromise);
|
|
17
|
-
CAP_PLUGIN_METHOD(getRemindersLists, CAPPluginReturnPromise);
|
|
18
|
-
CAP_PLUGIN_METHOD(createReminder, CAPPluginReturnPromise);
|
|
19
|
-
CAP_PLUGIN_METHOD(openCalendar, CAPPluginReturnNone);
|
|
20
|
-
CAP_PLUGIN_METHOD(openReminders, CAPPluginReturnNone);
|
|
21
|
-
CAP_PLUGIN_METHOD(listEventsInRange, CAPPluginReturnPromise);
|
|
22
|
-
CAP_PLUGIN_METHOD(deleteEventsById, CAPPluginReturnPromise);
|
|
23
|
-
CAP_PLUGIN_METHOD(createCalendar, CAPPluginReturnPromise);
|
|
24
|
-
CAP_PLUGIN_METHOD(deleteCalendar, CAPPluginReturnNone);
|
|
25
|
-
CAP_PLUGIN_METHOD(getRemindersFromLists, CAPPluginReturnPromise);
|
|
26
|
-
CAP_PLUGIN_METHOD(deleteRemindersById, CAPPluginReturnPromise);
|
|
27
|
-
CAP_PLUGIN_METHOD(requestWriteOnlyCalendarAccess, CAPPluginReturnPromise);
|
|
28
|
-
CAP_PLUGIN_METHOD(requestFullCalendarAccess, CAPPluginReturnPromise);
|
|
29
|
-
CAP_PLUGIN_METHOD(requestFullRemindersAccess, CAPPluginReturnPromise);
|
|
30
|
-
CAP_PLUGIN_METHOD(requestReadOnlyCalendarAccess, CAPPluginReturnPromise);
|
|
31
|
-
CAP_PLUGIN_METHOD(modifyEventWithPrompt, CAPPluginReturnPromise);
|
|
32
|
-
CAP_PLUGIN_METHOD(modifyEvent, CAPPluginReturnNone);
|
|
33
|
-
CAP_PLUGIN_METHOD(fetchAllCalendarSources, CAPPluginReturnPromise);
|
|
34
|
-
CAP_PLUGIN_METHOD(fetchAllRemindersSources, CAPPluginReturnPromise);
|
|
35
|
-
CAP_PLUGIN_METHOD(modifyReminder, CAPPluginReturnNone);
|
|
36
|
-
)
|