@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,648 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import EventKit
|
|
3
|
-
import Capacitor
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Please read the Capacitor iOS Plugin Development Guide
|
|
7
|
-
* here: https://capacitorjs.com/docs/plugins/ios
|
|
8
|
-
*/
|
|
9
|
-
@objc(CapacitorCalendarPlugin)
|
|
10
|
-
public class CapacitorCalendarPlugin: CAPPlugin {
|
|
11
|
-
private let eventStore = EKEventStore()
|
|
12
|
-
private lazy var calendar = CapacitorCalendar(bridge: self.bridge, eventStore: self.eventStore)
|
|
13
|
-
private lazy var reminders = CapacitorReminders(eventStore: self.eventStore)
|
|
14
|
-
|
|
15
|
-
@objc public func checkPermission(_ call: CAPPluginCall) {
|
|
16
|
-
guard let alias = call.getString("alias") else {
|
|
17
|
-
call.reject("[CapacitorCalendar.\(#function)] Permission name is not defined")
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
Task {
|
|
22
|
-
do {
|
|
23
|
-
try await handlePermissionCheck(for: alias, with: call)
|
|
24
|
-
} catch {
|
|
25
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not determine the status of the requested permission")
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
private func handlePermissionCheck(for alias: String, with call: CAPPluginCall) async throws {
|
|
31
|
-
let permissionsState: [String: String]
|
|
32
|
-
|
|
33
|
-
switch alias {
|
|
34
|
-
case "readCalendar":
|
|
35
|
-
permissionsState = try await calendar.checkAllPermissions()
|
|
36
|
-
case "writeCalendar":
|
|
37
|
-
permissionsState = try await calendar.checkAllPermissions()
|
|
38
|
-
case "readReminders":
|
|
39
|
-
permissionsState = try await reminders.checkAllPermissions()
|
|
40
|
-
case "writeReminders":
|
|
41
|
-
permissionsState = try await reminders.checkAllPermissions()
|
|
42
|
-
default:
|
|
43
|
-
throw CapacitorCalendarPluginError.unknownPermissionStatus
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
guard let permissionResult = permissionsState[alias] else {
|
|
47
|
-
throw CapacitorCalendarPluginError.unknownPermissionStatus
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
call.resolve(["result": permissionResult])
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@objc public func checkAllPermissions(_ call: CAPPluginCall) {
|
|
54
|
-
Task {
|
|
55
|
-
do {
|
|
56
|
-
let calendarPermissionsState = try await calendar.checkAllPermissions()
|
|
57
|
-
let remindersPermissionsState = try await reminders.checkAllPermissions()
|
|
58
|
-
call.resolve(calendarPermissionsState.merging(remindersPermissionsState) { (_, new) in new })
|
|
59
|
-
} catch {
|
|
60
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not determine the status of the requested permissions")
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@objc public func requestPermission(_ call: CAPPluginCall) {
|
|
67
|
-
guard let alias = call.getString("alias") else {
|
|
68
|
-
call.reject("[CapacitorCalendar.\(#function)] Permission name is not defined")
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
Task {
|
|
73
|
-
do {
|
|
74
|
-
switch alias {
|
|
75
|
-
case "writeCalendar":
|
|
76
|
-
let result = try await calendar.requestWriteAccessToEvents()
|
|
77
|
-
call.resolve(result)
|
|
78
|
-
case "readCalendar":
|
|
79
|
-
let result = try await calendar.requestFullAccessToEvents()
|
|
80
|
-
call.resolve(["result": result])
|
|
81
|
-
case "writeReminders":
|
|
82
|
-
let result = try await reminders.requestFullAccessToReminders()
|
|
83
|
-
call.resolve(["result": result])
|
|
84
|
-
case "readReminders":
|
|
85
|
-
let result = try await reminders.requestFullAccessToReminders()
|
|
86
|
-
call.resolve(["result": result])
|
|
87
|
-
default:
|
|
88
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not authorize \(alias)")
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
} catch {
|
|
92
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not authorize \(alias)")
|
|
93
|
-
return
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@objc public func requestAllPermissions(_ call: CAPPluginCall) {
|
|
99
|
-
Task {
|
|
100
|
-
do {
|
|
101
|
-
let calendarResult = try await calendar.requestFullAccessToEvents()
|
|
102
|
-
let remindersResult = try await reminders.requestFullAccessToReminders()
|
|
103
|
-
var result: [String: String] = [
|
|
104
|
-
"readCalendar": PermissionState.denied.rawValue,
|
|
105
|
-
"writeCalendar": PermissionState.denied.rawValue,
|
|
106
|
-
"readReminders": PermissionState.denied.rawValue,
|
|
107
|
-
"writeReminders": PermissionState.denied.rawValue
|
|
108
|
-
]
|
|
109
|
-
if calendarResult == PermissionState.granted.rawValue {
|
|
110
|
-
result["readCalendar"] = PermissionState.granted.rawValue
|
|
111
|
-
result["writeCalendar"] = PermissionState.granted.rawValue
|
|
112
|
-
}
|
|
113
|
-
if remindersResult == PermissionState.granted.rawValue {
|
|
114
|
-
result["readReminders"] = PermissionState.granted.rawValue
|
|
115
|
-
result["writeReminders"] = PermissionState.granted.rawValue
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
call.resolve(result)
|
|
119
|
-
} catch {
|
|
120
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not authorize all permissions")
|
|
121
|
-
return
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
@objc public func createEventWithPrompt(_ call: CAPPluginCall) {
|
|
127
|
-
let title = call.getString("title", "")
|
|
128
|
-
let location = call.getString("location")
|
|
129
|
-
let startDate = call.getDouble("startDate")
|
|
130
|
-
let endDate = call.getDouble("endDate")
|
|
131
|
-
let isAllDay = call.getBool("isAllDay")
|
|
132
|
-
let calendarId = call.getString("calendarId")
|
|
133
|
-
let notes = call.getString("notes")
|
|
134
|
-
let url = call.getString("url")
|
|
135
|
-
|
|
136
|
-
Task {
|
|
137
|
-
var eventParameters = EventCreationParameters(
|
|
138
|
-
title: title,
|
|
139
|
-
calendarId: calendarId,
|
|
140
|
-
location: location,
|
|
141
|
-
startDate: startDate,
|
|
142
|
-
endDate: endDate,
|
|
143
|
-
isAllDay: isAllDay,
|
|
144
|
-
notes: notes,
|
|
145
|
-
url: url
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
if let alertOffsetInMinutesSingle = call.getDouble("alertOffsetInMinutes") as Double? {
|
|
149
|
-
eventParameters.alertOffsetInMinutesSingle = alertOffsetInMinutesSingle
|
|
150
|
-
} else if let alertOffsetInMinutesMultiple = call.getArray("alertOffsetInMinutes") as? [Double]? {
|
|
151
|
-
eventParameters.alertOffsetInMinutesMultiple = alertOffsetInMinutesMultiple
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
do {
|
|
155
|
-
let result = try await calendar.createEventWithPrompt(with: eventParameters)
|
|
156
|
-
call.resolve(["result": result])
|
|
157
|
-
} catch {
|
|
158
|
-
call.reject("[CapacitorCalendar.\(#function)] Unable to retrieve view controller")
|
|
159
|
-
return
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
@objc public func modifyEventWithPrompt(_ call: CAPPluginCall) {
|
|
165
|
-
guard let id = call.getString("id") else {
|
|
166
|
-
call.reject("[CapacitorCalendar.\(#function)] Missing event id")
|
|
167
|
-
return
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
Task {
|
|
171
|
-
do {
|
|
172
|
-
let result: [String]
|
|
173
|
-
|
|
174
|
-
if let update = call.getObject("update") {
|
|
175
|
-
|
|
176
|
-
let title = update["title"] as? String
|
|
177
|
-
let calendarId = update["calendarId"] as? String
|
|
178
|
-
let location = update["location"] as? String
|
|
179
|
-
let startDate = update["startDate"] as? Double
|
|
180
|
-
let endDate = update["endDate"] as? Double
|
|
181
|
-
let isAllDay = update["isAllDay"] as? Bool
|
|
182
|
-
let notes = update["notes"] as? String
|
|
183
|
-
let url = update["url"] as? String
|
|
184
|
-
let alertOffsetInMinutesSingle = update["alertOffsetInMinutes"] as? Double
|
|
185
|
-
let alertOffsetInMinutesMultiple = update["alertOffsetInMinutes"] as? [Double]
|
|
186
|
-
|
|
187
|
-
var eventParameters = EventCreationParameters(
|
|
188
|
-
title: title,
|
|
189
|
-
calendarId: calendarId,
|
|
190
|
-
location: location,
|
|
191
|
-
startDate: startDate,
|
|
192
|
-
endDate: endDate,
|
|
193
|
-
isAllDay: isAllDay,
|
|
194
|
-
alertOffsetInMinutesSingle: alertOffsetInMinutesSingle,
|
|
195
|
-
alertOffsetInMinutesMultiple: alertOffsetInMinutesMultiple,
|
|
196
|
-
notes: notes,
|
|
197
|
-
url: url
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
result = try await calendar.modifyEventWithPrompt(id: id, update: eventParameters)
|
|
201
|
-
} else {
|
|
202
|
-
result = try await calendar.modifyEventWithPrompt(id: id)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
call.resolve(["result": result])
|
|
206
|
-
} catch {
|
|
207
|
-
call.reject("[CapacitorCalendar.\(#function)] Unable to modify event")
|
|
208
|
-
return
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
@objc public func selectCalendarsWithPrompt(_ call: CAPPluginCall) {
|
|
214
|
-
guard let selectionStyle = call.getInt("selectionStyle") else {
|
|
215
|
-
call.reject("[CapacitorCalendar.\(#function)] Selection style was not provided")
|
|
216
|
-
return
|
|
217
|
-
}
|
|
218
|
-
guard let displayStyle = call.getInt("displayStyle") else {
|
|
219
|
-
call.reject("[CapacitorCalendar.\(#function)] Display style was not provided")
|
|
220
|
-
return
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
Task {
|
|
224
|
-
do {
|
|
225
|
-
let result = try await calendar.selectCalendarsWithPrompt(selectionStyle: selectionStyle, displayStyle: displayStyle)
|
|
226
|
-
call.resolve(["result": result])
|
|
227
|
-
} catch {
|
|
228
|
-
call.reject("[CapacitorCalendar.\(#function)] Calendars selection prompt got canceled")
|
|
229
|
-
return
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
@objc public func listCalendars(_ call: CAPPluginCall) {
|
|
235
|
-
call.resolve(["result": calendar.listCalendars()])
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
@objc public func getDefaultCalendar(_ call: CAPPluginCall) {
|
|
239
|
-
do {
|
|
240
|
-
try call.resolve(["result": calendar.getDefaultCalendar() ?? NSNull()])
|
|
241
|
-
} catch {
|
|
242
|
-
call.reject("[CapacitorCalendar.\(#function)] No default calendar was found")
|
|
243
|
-
return
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
@objc public func createEvent(_ call: CAPPluginCall) {
|
|
248
|
-
guard let title = call.getString("title") else {
|
|
249
|
-
call.reject("[CapacitorCalendar.\(#function)] A title for the event was not provided")
|
|
250
|
-
return
|
|
251
|
-
}
|
|
252
|
-
let location = call.getString("location")
|
|
253
|
-
let startDate = call.getDouble("startDate")
|
|
254
|
-
let endDate = call.getDouble("endDate")
|
|
255
|
-
let isAllDay = call.getBool("isAllDay")
|
|
256
|
-
let calendarId = call.getString("calendarId")
|
|
257
|
-
let notes = call.getString("notes")
|
|
258
|
-
let url = call.getString("url")
|
|
259
|
-
|
|
260
|
-
var eventParameters = EventCreationParameters(
|
|
261
|
-
title: title,
|
|
262
|
-
calendarId: calendarId,
|
|
263
|
-
location: location,
|
|
264
|
-
startDate: startDate,
|
|
265
|
-
endDate: endDate,
|
|
266
|
-
isAllDay: isAllDay,
|
|
267
|
-
notes: notes,
|
|
268
|
-
url: url
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
if let alertOffsetInMinutesSingle = call.getDouble("alertOffsetInMinutes") as Double? {
|
|
272
|
-
eventParameters.alertOffsetInMinutesSingle = alertOffsetInMinutesSingle
|
|
273
|
-
} else if let alertOffsetInMinutesMultiple = call.getArray("alertOffsetInMinutes") as? [Double]? {
|
|
274
|
-
eventParameters.alertOffsetInMinutesMultiple = alertOffsetInMinutesMultiple
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
do {
|
|
278
|
-
let id = try calendar.createEvent(with: eventParameters)
|
|
279
|
-
call.resolve(["result": id])
|
|
280
|
-
} catch {
|
|
281
|
-
call.reject("[CapacitorCalendar.\(#function)] Unable to create event")
|
|
282
|
-
return
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
@objc public func modifyEvent(_ call: CAPPluginCall) {
|
|
287
|
-
guard let eventId = call.getString("id") else {
|
|
288
|
-
call.reject("[CapacitorCalendar.\(#function)] An id for the event was not provided")
|
|
289
|
-
return
|
|
290
|
-
}
|
|
291
|
-
guard let update = call.getObject("update") else {
|
|
292
|
-
call.reject("[CapacitorCalendar.\(#function)] An update for the event was not provided")
|
|
293
|
-
return
|
|
294
|
-
}
|
|
295
|
-
let span = call.getInt("span", 0)
|
|
296
|
-
let title = update["title"] as? String
|
|
297
|
-
let calendarId = update["calendarId"] as? String
|
|
298
|
-
let location = update["location"] as? String
|
|
299
|
-
let startDate = update["startDate"] as? Double
|
|
300
|
-
let endDate = update["endDate"] as? Double
|
|
301
|
-
let isAllDay = update["isAllDay"] as? Bool
|
|
302
|
-
let notes = update["notes"] as? String
|
|
303
|
-
let url = update["url"] as? String
|
|
304
|
-
let alertOffsetInMinutesSingle = update["alertOffsetInMinutes"] as? Double
|
|
305
|
-
let alertOffsetInMinutesMultiple = update["alertOffsetInMinutes"] as? [Double]
|
|
306
|
-
|
|
307
|
-
do {
|
|
308
|
-
var eventParameters = EventCreationParameters(
|
|
309
|
-
title: title,
|
|
310
|
-
calendarId: calendarId,
|
|
311
|
-
location: location,
|
|
312
|
-
startDate: startDate,
|
|
313
|
-
endDate: endDate,
|
|
314
|
-
isAllDay: isAllDay,
|
|
315
|
-
alertOffsetInMinutesSingle: alertOffsetInMinutesSingle,
|
|
316
|
-
alertOffsetInMinutesMultiple: alertOffsetInMinutesMultiple,
|
|
317
|
-
notes: notes,
|
|
318
|
-
url: url
|
|
319
|
-
)
|
|
320
|
-
try calendar.modifyEvent(id: eventId, span: EKSpan(rawValue: span) ?? .thisEvent, update: eventParameters)
|
|
321
|
-
call.resolve()
|
|
322
|
-
} catch {
|
|
323
|
-
call.reject("[CapacitorCalendar.\(#function)] Unable to modify event")
|
|
324
|
-
return
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
@objc public func getDefaultRemindersList(_ call: CAPPluginCall) {
|
|
329
|
-
do {
|
|
330
|
-
try call.resolve(["result": reminders.getDefaultRemindersList() ?? NSNull()])
|
|
331
|
-
} catch {
|
|
332
|
-
call.reject("[CapacitorCalendar.\(#function)] No default Reminders list was found")
|
|
333
|
-
return
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
@objc public func getRemindersLists(_ call: CAPPluginCall) {
|
|
338
|
-
call.resolve(["result": reminders.getRemindersLists()])
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
@objc public func createReminder (_ call: CAPPluginCall) {
|
|
342
|
-
guard let title = call.getString("title") else {
|
|
343
|
-
call.reject("[CapacitorCalendar.\(#function)] A title for the reminder was not provided")
|
|
344
|
-
return
|
|
345
|
-
}
|
|
346
|
-
let listId = call.getString("listId")
|
|
347
|
-
let priority = call.getInt("priority")
|
|
348
|
-
let isCompleted = call.getBool("isCompleted")
|
|
349
|
-
let startDate = call.getDouble("startDate")
|
|
350
|
-
let dueDate = call.getDouble("dueDate")
|
|
351
|
-
let completionDate = call.getDouble("completionDate")
|
|
352
|
-
let notes = call.getString("notes")
|
|
353
|
-
let url = call.getString("url")
|
|
354
|
-
let location = call.getString("location")
|
|
355
|
-
|
|
356
|
-
var recurrence: RecurrenceParameters?
|
|
357
|
-
if let recurrenceData = call.getObject("recurrence") {
|
|
358
|
-
guard let frequency = recurrenceData["frequency"] as? Int else {
|
|
359
|
-
call.reject("[CapacitorCalendar.\(#function)] Frequency must be provided when using recurrence")
|
|
360
|
-
return
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
guard let interval = recurrenceData["interval"] as? Int, interval > 0 else {
|
|
364
|
-
call.reject("[CapacitorCalendar.\(#function)] Interval must be greater than 0 when using recurrence")
|
|
365
|
-
return
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
let end = recurrenceData["end"] as? Double
|
|
369
|
-
|
|
370
|
-
recurrence = RecurrenceParameters(frequency: frequency, interval: interval, end: end)
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
let reminderParams = ReminderCreationParameters(
|
|
374
|
-
title: title,
|
|
375
|
-
listId: listId,
|
|
376
|
-
priority: priority,
|
|
377
|
-
isCompleted: isCompleted,
|
|
378
|
-
startDate: startDate,
|
|
379
|
-
dueDate: dueDate,
|
|
380
|
-
completionDate: completionDate,
|
|
381
|
-
notes: notes,
|
|
382
|
-
url: url,
|
|
383
|
-
location: location,
|
|
384
|
-
recurrence: recurrence
|
|
385
|
-
)
|
|
386
|
-
|
|
387
|
-
do {
|
|
388
|
-
let id = try reminders.createReminder(with: reminderParams)
|
|
389
|
-
call.resolve(["result": id])
|
|
390
|
-
} catch {
|
|
391
|
-
call.reject("[CapacitorCalendar.\(#function)] Unable to create reminder")
|
|
392
|
-
return
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
@objc public func openCalendar(_ call: CAPPluginCall) {
|
|
397
|
-
let interval: Double
|
|
398
|
-
if let date = call.getDouble("date") {
|
|
399
|
-
interval = Date(timeIntervalSince1970: date / 1000).timeIntervalSinceReferenceDate
|
|
400
|
-
} else {
|
|
401
|
-
interval = Date.timeIntervalSinceReferenceDate
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
Task {
|
|
405
|
-
do {
|
|
406
|
-
try await calendar.openCalendar(date: interval)
|
|
407
|
-
} catch {
|
|
408
|
-
call.reject("[CapacitorCalendar.\(#function)] Unable to open the calendar")
|
|
409
|
-
return
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
@objc public func openReminders(_ call: CAPPluginCall) {
|
|
415
|
-
Task {
|
|
416
|
-
do {
|
|
417
|
-
try await reminders.openReminders()
|
|
418
|
-
} catch {
|
|
419
|
-
call.reject("[CapacitorCalendar.\(#function)] Unable to open reminders")
|
|
420
|
-
return
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
@objc public func listEventsInRange(_ call: CAPPluginCall) {
|
|
426
|
-
guard let startDate = call.getDouble("startDate") else {
|
|
427
|
-
call.reject("[CapacitorCalendar.\(#function)] A start date was not provided")
|
|
428
|
-
return
|
|
429
|
-
}
|
|
430
|
-
guard let endDate = call.getDouble("endDate") else {
|
|
431
|
-
call.reject("[CapacitorCalendar.\(#function)] An end date was not provided")
|
|
432
|
-
return
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
do {
|
|
436
|
-
try call.resolve(["result": calendar.listEventsInRange(startDate: startDate, endDate: endDate)])
|
|
437
|
-
} catch {
|
|
438
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not get the list of events in requested range")
|
|
439
|
-
return
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
@objc public func deleteEventsById(_ call: CAPPluginCall) {
|
|
444
|
-
guard let eventIds = call.getArray("ids") else {
|
|
445
|
-
call.reject("[CapacitorCalendar.\(#function)] Event ids were not provided")
|
|
446
|
-
return
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
Task {
|
|
450
|
-
do {
|
|
451
|
-
let deleteResult = try await calendar.deleteEventsById(ids: eventIds)
|
|
452
|
-
call.resolve([
|
|
453
|
-
"result": [
|
|
454
|
-
"deleted": deleteResult.deleted,
|
|
455
|
-
"failed": deleteResult.failed
|
|
456
|
-
]
|
|
457
|
-
])
|
|
458
|
-
} catch {
|
|
459
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not delete events")
|
|
460
|
-
return
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
@objc public func createCalendar(_ call: CAPPluginCall) {
|
|
466
|
-
guard let title = call.getString("title") else {
|
|
467
|
-
call.reject("[CapacitorCalendar.\(#function)] A title for the calendar was not provided")
|
|
468
|
-
return
|
|
469
|
-
}
|
|
470
|
-
let color = call.getString("color")
|
|
471
|
-
let sourceId = call.getString("sourceId")
|
|
472
|
-
|
|
473
|
-
do {
|
|
474
|
-
let id = try calendar.createCalendar(title: title, color: color, sourceId: sourceId)
|
|
475
|
-
call.resolve(["result": id])
|
|
476
|
-
} catch {
|
|
477
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not create calendar")
|
|
478
|
-
return
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
@objc public func deleteCalendar(_ call: CAPPluginCall) {
|
|
483
|
-
guard let id = call.getString("id") else {
|
|
484
|
-
call.reject("[CapacitorCalendar.\(#function)] An id for the calendar to delete should be provided")
|
|
485
|
-
return
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
do {
|
|
489
|
-
try calendar.deleteCalendar(id: id)
|
|
490
|
-
call.resolve()
|
|
491
|
-
} catch {
|
|
492
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not delete calendar")
|
|
493
|
-
return
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
@objc public func getRemindersFromLists(_ call: CAPPluginCall) {
|
|
498
|
-
let ids = call.getArray("listIds")
|
|
499
|
-
|
|
500
|
-
Task {
|
|
501
|
-
do {
|
|
502
|
-
try call.resolve(["result": await reminders.getRemindersFromLists(listIds: ids)])
|
|
503
|
-
} catch {
|
|
504
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not get the reminders from lists")
|
|
505
|
-
return
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
@objc public func deleteRemindersById(_ call: CAPPluginCall) {
|
|
511
|
-
guard let ids = call.getArray("ids") else {
|
|
512
|
-
call.reject("[CapacitorCalendar.\(#function)] Reminder ids were not provided")
|
|
513
|
-
return
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
Task {
|
|
517
|
-
do {
|
|
518
|
-
let deleteResult = try await reminders.deleteRemindersById(ids: ids)
|
|
519
|
-
call.resolve([
|
|
520
|
-
"result": [
|
|
521
|
-
"deleted": deleteResult.deleted,
|
|
522
|
-
"failed": deleteResult.failed
|
|
523
|
-
]
|
|
524
|
-
])
|
|
525
|
-
} catch {
|
|
526
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not delete the reminders")
|
|
527
|
-
return
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
@objc public func requestWriteOnlyCalendarAccess(_ call: CAPPluginCall) {
|
|
533
|
-
Task {
|
|
534
|
-
do {
|
|
535
|
-
let result = try await calendar.requestWriteAccessToEvents()
|
|
536
|
-
call.resolve(result)
|
|
537
|
-
} catch {
|
|
538
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not authorize write access")
|
|
539
|
-
return
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
@objc public func requestReadOnlyCalendarAccess(_ call: CAPPluginCall) {
|
|
545
|
-
call.unimplemented("[CapacitorCalendar.\(#function)] Not implemented on iOS")
|
|
546
|
-
return
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
@objc public func requestFullCalendarAccess(_ call: CAPPluginCall) {
|
|
550
|
-
Task {
|
|
551
|
-
do {
|
|
552
|
-
let result = try await calendar.requestFullAccessToEvents()
|
|
553
|
-
call.resolve(["result": result])
|
|
554
|
-
} catch {
|
|
555
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not authorize full calendar access")
|
|
556
|
-
return
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
@objc public func requestFullRemindersAccess(_ call: CAPPluginCall) {
|
|
562
|
-
Task {
|
|
563
|
-
do {
|
|
564
|
-
let result = try await reminders.requestFullAccessToReminders()
|
|
565
|
-
call.resolve(["result": result])
|
|
566
|
-
} catch {
|
|
567
|
-
call.reject("[CapacitorCalendar.\(#function)] Could not authorize full reminders access")
|
|
568
|
-
return
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
@objc public func fetchAllCalendarSources(_ call: CAPPluginCall) {
|
|
574
|
-
do {
|
|
575
|
-
call.resolve(["result": try calendar.fetchAllCalendarSources()])
|
|
576
|
-
} catch {
|
|
577
|
-
call.reject("[CapacitorCalendar.\(#function)] Unable to fetch calendar sources")
|
|
578
|
-
return
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
@objc public func fetchAllRemindersSources(_ call: CAPPluginCall) {
|
|
583
|
-
do {
|
|
584
|
-
call.resolve(["result": try reminders.fetchAllRemindersSources()])
|
|
585
|
-
} catch {
|
|
586
|
-
call.reject("[CapacitorCalendar.\(#function)] Unable to fetch calendar sources")
|
|
587
|
-
return
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
@objc public func modifyReminder(_ call: CAPPluginCall) {
|
|
592
|
-
guard let reminderId = call.getString("id") else {
|
|
593
|
-
call.reject("[CapacitorCalendar.\(#function)] An id for the reminder was not provided")
|
|
594
|
-
return
|
|
595
|
-
}
|
|
596
|
-
guard let update = call.getObject("update") else {
|
|
597
|
-
call.reject("[CapacitorCalendar.\(#function)] An update for the reminder was not provided")
|
|
598
|
-
return
|
|
599
|
-
}
|
|
600
|
-
let title = update["title"] as? String
|
|
601
|
-
let listId = update["listId"] as? String
|
|
602
|
-
let priority = update["priority"] as? Int
|
|
603
|
-
let isCompleted = update["isCompleted"] as? Bool
|
|
604
|
-
let startDate = update["startDate"] as? Double
|
|
605
|
-
let dueDate = update["dueDate"] as? Double
|
|
606
|
-
let completionDate = update["completionDate"] as? Double
|
|
607
|
-
let notes = update["notes"] as? String
|
|
608
|
-
let url = update["url"] as? String
|
|
609
|
-
let location = update["location"] as? String
|
|
610
|
-
var recurrence: RecurrenceParameters?
|
|
611
|
-
if let recurrenceData = update["recurrence"] as? JSObject {
|
|
612
|
-
guard let frequency = recurrenceData["frequency"] as? Int else {
|
|
613
|
-
call.reject("[CapacitorCalendar.\(#function)] Frequency must be provided when using recurrence")
|
|
614
|
-
return
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
guard let interval = recurrenceData["interval"] as? Int, interval > 0 else {
|
|
618
|
-
call.reject("[CapacitorCalendar.\(#function)] Interval must be greater than 0 when using recurrence")
|
|
619
|
-
return
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
let end = recurrenceData["end"] as? Double
|
|
623
|
-
|
|
624
|
-
recurrence = RecurrenceParameters(frequency: frequency, interval: interval, end: end)
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
do {
|
|
628
|
-
var reminderUpdate = ReminderCreationParameters(
|
|
629
|
-
title: title,
|
|
630
|
-
listId: listId,
|
|
631
|
-
priority: priority,
|
|
632
|
-
isCompleted: isCompleted,
|
|
633
|
-
startDate: startDate,
|
|
634
|
-
dueDate: dueDate,
|
|
635
|
-
completionDate: completionDate,
|
|
636
|
-
notes: notes,
|
|
637
|
-
url: url,
|
|
638
|
-
location: location,
|
|
639
|
-
recurrence: recurrence
|
|
640
|
-
)
|
|
641
|
-
try reminders.modifyReminder(id: reminderId, update: reminderUpdate)
|
|
642
|
-
call.resolve()
|
|
643
|
-
} catch {
|
|
644
|
-
call.reject("[CapacitorCalendar.\(#function)] Unable to modify reminder")
|
|
645
|
-
return
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// PermissionError.swift
|
|
3
|
-
// Plugin
|
|
4
|
-
//
|
|
5
|
-
// Created by Ehsan Barooni on 27.02.24.
|
|
6
|
-
// Copyright © 2024 Max Lynch. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import Foundation
|
|
10
|
-
|
|
11
|
-
public enum CapacitorCalendarPluginError: Error {
|
|
12
|
-
case unknownPermissionStatus
|
|
13
|
-
case eventStoreAuthorization
|
|
14
|
-
case viewControllerUnavailable
|
|
15
|
-
case unknownActionEventCreationPrompt
|
|
16
|
-
case unableToOpenCalendar
|
|
17
|
-
case unableToOpenReminders
|
|
18
|
-
case undefinedEvent
|
|
19
|
-
case unableToParseColor
|
|
20
|
-
case unableToCreateCalendar
|
|
21
|
-
case calendarNotFound
|
|
22
|
-
}
|