@ebarooni/capacitor-calendar 8.9.0 → 8.11.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/README.md +114 -59
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +20 -4
- package/android/src/main/java/dev/barooni/capacitor/calendar/PluginError.kt +41 -22
- package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt +129 -3
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/CalendarInfo.kt +1 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventRecurrenceRule.kt +4 -3
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventInput.kt +4 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventInput.kt +4 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventWithPromptInput.kt +4 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/GetEventByIdInput.kt +13 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ListEventsInRangeInput.kt +5 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEvent.kt +8 -2
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEventWithPromptInput.kt +1 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/GetDefaultCalendarResult.kt +1 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/GetEventByIdResult.kt +15 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/ListCalendarsResult.kt +1 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/ListEventsInRangeResult.kt +47 -43
- package/android/src/main/java/dev/barooni/capacitor/calendar/utils/ImplementationHelper.kt +61 -3
- package/android/src/main/java/dev/barooni/capacitor/calendar/utils/PluginCallRejecter.kt +69 -0
- package/dist/docs.json +206 -8
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schemas/enums/capacitor-calendar-error-code.d.ts +31 -0
- package/dist/esm/schemas/enums/capacitor-calendar-error-code.js +31 -0
- package/dist/esm/schemas/enums/capacitor-calendar-error-code.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar.d.ts +3 -1
- package/dist/esm/schemas/interfaces/calendar.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-event-options.d.ts +2 -1
- package/dist/esm/schemas/interfaces/delete-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.d.ts +2 -1
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/get-event-by-id-options.d.ts +11 -0
- package/dist/esm/schemas/interfaces/get-event-by-id-options.js +2 -0
- package/dist/esm/schemas/interfaces/get-event-by-id-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-event-by-id-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-event-by-id-result.js +2 -0
- package/dist/esm/schemas/interfaces/get-event-by-id-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-options.d.ts +8 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/modify-event-options.d.ts +11 -0
- package/dist/esm/schemas/interfaces/modify-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.d.ts +10 -0
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.js.map +1 -1
- package/dist/esm/sub-definitions/event-operations.d.ts +33 -0
- package/dist/esm/sub-definitions/event-operations.js.map +1 -1
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +3 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +34 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +34 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorCalendarPlugin.swift +18 -4
- package/ios/Plugin/Implementation/CapacitorCalendar.swift +41 -7
- package/ios/Plugin/Models/Inputs/CreateEventInput.swift +1 -1
- package/ios/Plugin/Models/Inputs/CreateEventWithPromptInput.swift +61 -70
- package/ios/Plugin/Models/Inputs/DeleteEventInput.swift +7 -0
- package/ios/Plugin/Models/Inputs/DeleteEventWithPromptInput.swift +7 -0
- package/ios/Plugin/Models/Inputs/GetEventByIdInput.swift +16 -0
- package/ios/Plugin/Models/Inputs/ListEventsInRangeInput.swift +20 -0
- package/ios/Plugin/Models/Inputs/ModifyEventInput.swift +13 -23
- package/ios/Plugin/Models/Inputs/ModifyEventWithPromptInput.swift +10 -5
- package/ios/Plugin/Models/Results/GetEventByIdResult.swift +27 -0
- package/ios/Plugin/Models/Structs/RecurrenceInput.swift +14 -0
- package/ios/Plugin/PluginConfig.swift +1 -0
- package/ios/Plugin/PluginError.swift +41 -0
- package/ios/Plugin/Utils/ImplementationHelper.swift +33 -2
- package/ios/Plugin/Utils/PluginCallRejecter.swift +36 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -154,13 +154,28 @@ Add the appropriate usage description keys to `ios/App/App/Info.plist`. Starting
|
|
|
154
154
|
|
|
155
155
|
## Error codes
|
|
156
156
|
|
|
157
|
-
On Android and iOS, a rejected call can expose `error.code` (stable category) and `error.message` (exact cause). Compare codes with the exported `CapacitorCalendarErrorCode` enum.
|
|
157
|
+
On Android and iOS, a rejected call can expose `error.code` (stable category) and `error.message` (exact cause). Compare codes with the exported `CapacitorCalendarErrorCode` enum. Not every reject has a code yet; later releases add more catalog cases.
|
|
158
158
|
|
|
159
159
|
Defined codes:
|
|
160
160
|
|
|
161
|
-
| Code | Name | When
|
|
162
|
-
| :------------- | :------------------- |
|
|
163
|
-
| `EB-CLDR-
|
|
161
|
+
| Code | Name | When |
|
|
162
|
+
| :------------- | :------------------- | :-------------------------------------------------------------------------------- |
|
|
163
|
+
| `EB-CLDR-0001` | `InvalidArgument` | A required argument is missing or invalid. |
|
|
164
|
+
| `EB-CLDR-0002` | `NotFound` | The requested calendar, event, list, reminder, or calendar source does not exist. |
|
|
165
|
+
| `EB-CLDR-0004` | `IoError` | A calendar store read or write failed. |
|
|
166
|
+
| `EB-CLDR-0005` | `NotSupported` | The device cannot open the calendar UI, reminders UI, or target URL. |
|
|
167
|
+
| `EB-CLDR-0020` | `PermissionDenied` | Calendar access was denied. |
|
|
168
|
+
| `EB-CLDR-0100` | `MissingDeclaration` | Required Info.plist usage description or AndroidManifest permission is not set. |
|
|
169
|
+
|
|
170
|
+
Android rejects a non-numeric or empty calendar or event `id` as `InvalidArgument`. iOS looks up the string in the system calendar store and may reject as `NotFound` when nothing matches.
|
|
171
|
+
|
|
172
|
+
`IoError`: Android and iOS map store failures such as failed create/delete ID retrieval and delete failures. Other calendar store errors that are not permission or launch failures also use this code. On iOS, EventKit store or system rejects use this code, including some authorization-related failures; Android permission-provider denials still use `PermissionDenied` (`EB-CLDR-0020`). On iOS, this code also covers the edit-prompt `processFailed` outcome.
|
|
173
|
+
|
|
174
|
+
`NotSupported`: Android maps a missing calendar activity handler (`ActivityNotFoundException`, for example `openCalendar`) to this code. iOS maps launch and URL failures (`Failed to launch calendar app.`, reminders, `Unable to open URL.`).
|
|
175
|
+
|
|
176
|
+
On Android, calendar operations that fail with a permission error reject with `PermissionDenied` (`EB-CLDR-0020`). Permission check and request APIs still resolve `"denied"` on Android and iOS; they do not reject with `0020`.
|
|
177
|
+
|
|
178
|
+
For Android and iOS wraps of system store, launch, and permission failures, the message starts with a fixed sentence. If the OS provides a different detail, it is appended in parentheses.
|
|
164
179
|
|
|
165
180
|
## Quick Start
|
|
166
181
|
|
|
@@ -338,6 +353,7 @@ See [BREAKING.md](BREAKING.md) for breaking changes and migration steps.
|
|
|
338
353
|
- [`deleteEvent(...)`](#deleteevent)
|
|
339
354
|
- [`deleteEventWithPrompt(...)`](#deleteeventwithprompt)
|
|
340
355
|
- [`listEventsInRange(...)`](#listeventsinrange)
|
|
356
|
+
- [`getEventById(...)`](#geteventbyid)
|
|
341
357
|
- [`commit()`](#commit)
|
|
342
358
|
- [`selectCalendarsWithPrompt(...)`](#selectcalendarswithprompt)
|
|
343
359
|
- [`fetchAllCalendarSources()`](#fetchallcalendarsources)
|
|
@@ -585,6 +601,7 @@ modifyEvent(options: ModifyEventOptions) => Promise<void>
|
|
|
585
601
|
```
|
|
586
602
|
|
|
587
603
|
Modifies an event.
|
|
604
|
+
Fields that you omit keep their current values.
|
|
588
605
|
|
|
589
606
|
| Param | Type |
|
|
590
607
|
| ------------- | ----------------------------------------------------------------- |
|
|
@@ -664,6 +681,7 @@ Retrieves events that overlap a date range.
|
|
|
664
681
|
|
|
665
682
|
An event is included when its time interval intersects `[from, to]`, including
|
|
666
683
|
multi-day events that span the range without starting or ending inside it.
|
|
684
|
+
Pass `calendarIds` to search only some calendars.
|
|
667
685
|
|
|
668
686
|
| Param | Type |
|
|
669
687
|
| ------------- | ----------------------------------------------------------------------------- |
|
|
@@ -677,6 +695,28 @@ multi-day events that span the range without starting or ending inside it.
|
|
|
677
695
|
|
|
678
696
|
---
|
|
679
697
|
|
|
698
|
+
### getEventById(...)
|
|
699
|
+
|
|
700
|
+
```typescript
|
|
701
|
+
getEventById(options: GetEventByIdOptions) => Promise<GetEventByIdResult>
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
Retrieves an event by id.
|
|
705
|
+
|
|
706
|
+
For a recurring event, the result is the first occurrence on iOS and the series master on Android.
|
|
707
|
+
|
|
708
|
+
| Param | Type |
|
|
709
|
+
| ------------- | ------------------------------------------------------------------- |
|
|
710
|
+
| **`options`** | <code><a href="#geteventbyidoptions">GetEventByIdOptions</a></code> |
|
|
711
|
+
|
|
712
|
+
**Returns:** <code>Promise<<a href="#geteventbyidresult">GetEventByIdResult</a>></code>
|
|
713
|
+
|
|
714
|
+
**Since:** 8.11.0
|
|
715
|
+
|
|
716
|
+
**Platform:** Android, iOS
|
|
717
|
+
|
|
718
|
+
---
|
|
719
|
+
|
|
680
720
|
### commit()
|
|
681
721
|
|
|
682
722
|
```typescript
|
|
@@ -1180,21 +1220,22 @@ Options for {@link CalendarAccess#requestPermission}.
|
|
|
1180
1220
|
|
|
1181
1221
|
#### ModifyEventWithPromptOptions
|
|
1182
1222
|
|
|
1183
|
-
| Prop | Type | Description | Since
|
|
1184
|
-
| ------------------ | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1185
|
-
| **`alerts`** | <code>number[]</code> | Alert times in minutes relative to the event start. Use negative numbers for reminders before the start, and positive numbers for reminders after the start. On iOS only 2 alerts are supported. | 7.1.0
|
|
1186
|
-
| **`availability`** | <code><a href="#eventavailability">EventAvailability</a></code> | | 7.1.0
|
|
1187
|
-
| **`calendarId`** | <code>string</code> | | 0.1.0
|
|
1188
|
-
| **`description`** | <code>string</code> | | 7.1.0
|
|
1189
|
-
| **`endDate`** | <code>number</code> | | 0.1.0
|
|
1190
|
-
| **`id`** | <code>string</code> | The ID of the event to be modified. | 7.1.0
|
|
1191
|
-
| **`
|
|
1192
|
-
| **`
|
|
1193
|
-
| **`
|
|
1194
|
-
| **`
|
|
1195
|
-
| **`
|
|
1196
|
-
| **`
|
|
1197
|
-
| **`
|
|
1223
|
+
| Prop | Type | Description | Since | Platform |
|
|
1224
|
+
| ------------------ | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------ | ------------ |
|
|
1225
|
+
| **`alerts`** | <code>number[]</code> | Alert times in minutes relative to the event start. Use negative numbers for reminders before the start, and positive numbers for reminders after the start. On iOS only 2 alerts are supported. | 7.1.0 | iOS |
|
|
1226
|
+
| **`availability`** | <code><a href="#eventavailability">EventAvailability</a></code> | | 7.1.0 | Android, iOS |
|
|
1227
|
+
| **`calendarId`** | <code>string</code> | | 0.1.0 | iOS |
|
|
1228
|
+
| **`description`** | <code>string</code> | | 7.1.0 | Android, iOS |
|
|
1229
|
+
| **`endDate`** | <code>number</code> | | 0.1.0 | Android, iOS |
|
|
1230
|
+
| **`id`** | <code>string</code> | The ID of the event to be modified. | 7.1.0 | Android, iOS |
|
|
1231
|
+
| **`instanceDate`** | <code>number</code> | The start time of the occurrence to modify, in milliseconds since the epoch. Use `startDate` from `listEventsInRange`. If omitted, the first occurrence of a recurring series is the target. | 8.11.0 | iOS |
|
|
1232
|
+
| **`invitees`** | <code>string[]</code> | An array of emails to invite. | 7.1.0 | Android |
|
|
1233
|
+
| **`isAllDay`** | <code>boolean</code> | | 0.1.0 | Android, iOS |
|
|
1234
|
+
| **`location`** | <code>string</code> | | 0.1.0 | Android, iOS |
|
|
1235
|
+
| **`recurrence`** | <code><a href="#eventrecurrencerule">EventRecurrenceRule</a></code> | Rules for creating a recurring event. | 7.3.0 | Android, iOS |
|
|
1236
|
+
| **`startDate`** | <code>number</code> | | 0.1.0 | Android, iOS |
|
|
1237
|
+
| **`title`** | <code>string</code> | | 0.1.0 | Android, iOS |
|
|
1238
|
+
| **`url`** | <code>string</code> | | 0.1.0 | iOS |
|
|
1198
1239
|
|
|
1199
1240
|
#### CreateEventResult
|
|
1200
1241
|
|
|
@@ -1235,25 +1276,26 @@ Options for {@link CalendarAccess#requestPermission}.
|
|
|
1235
1276
|
|
|
1236
1277
|
#### ModifyEventOptions
|
|
1237
1278
|
|
|
1238
|
-
| Prop | Type | Description
|
|
1239
|
-
| ------------------ | ------------------------------------------------------------------- |
|
|
1240
|
-
| **`alerts`** | <code>number[]</code> | Alert times in minutes relative to the event start. Use negative numbers for alerts before the start, and positive numbers for alerts after the start.
|
|
1241
|
-
| **`attendees`** | <code>EventGuest[]</code> | The event guests.
|
|
1242
|
-
| **`availability`** | <code><a href="#eventavailability">EventAvailability</a></code> |
|
|
1243
|
-
| **`calendarId`** | <code>string</code> |
|
|
1244
|
-
| **`color`** | <code>string</code> |
|
|
1245
|
-
| **`description`** | <code>string</code> |
|
|
1246
|
-
| **`duration`** | <code>string</code> | Duration of the event in RFC2445 format.
|
|
1247
|
-
| **`endDate`** | <code>number</code> |
|
|
1248
|
-
| **`id`** | <code>string</code> | The ID of the event to be modified.
|
|
1249
|
-
| **`
|
|
1250
|
-
| **`
|
|
1251
|
-
| **`
|
|
1252
|
-
| **`
|
|
1253
|
-
| **`
|
|
1254
|
-
| **`
|
|
1255
|
-
| **`
|
|
1256
|
-
| **`
|
|
1279
|
+
| Prop | Type | Description | Default | Since | Platform |
|
|
1280
|
+
| ------------------ | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ------ | ------------ |
|
|
1281
|
+
| **`alerts`** | <code>number[]</code> | Alert times in minutes relative to the event start. Use negative numbers for alerts before the start, and positive numbers for alerts after the start. | | 7.1.0 | Android, iOS |
|
|
1282
|
+
| **`attendees`** | <code>EventGuest[]</code> | The event guests. | | 7.1.0 | Android |
|
|
1283
|
+
| **`availability`** | <code><a href="#eventavailability">EventAvailability</a></code> | | | 7.1.0 | Android, iOS |
|
|
1284
|
+
| **`calendarId`** | <code>string</code> | | | 0.1.0 | Android, iOS |
|
|
1285
|
+
| **`color`** | <code>string</code> | | | 7.1.0 | Android |
|
|
1286
|
+
| **`description`** | <code>string</code> | | | 7.1.0 | Android, iOS |
|
|
1287
|
+
| **`duration`** | <code>string</code> | Duration of the event in RFC2445 format. | | 7.1.0 | Android |
|
|
1288
|
+
| **`endDate`** | <code>number</code> | | | 0.1.0 | Android, iOS |
|
|
1289
|
+
| **`id`** | <code>string</code> | The ID of the event to be modified. | | 7.1.0 | Android, iOS |
|
|
1290
|
+
| **`instanceDate`** | <code>number</code> | The start time of the occurrence to modify, in milliseconds since the epoch. Use `startDate` from `listEventsInRange`. If omitted, the first occurrence of a recurring series is the target. The call rejects when `recurrence` is also set and `span` is `THIS_EVENT`. Use `THIS_AND_FUTURE_EVENTS` to change the rule from this occurrence. | | 8.11.0 | iOS |
|
|
1291
|
+
| **`isAllDay`** | <code>boolean</code> | | | 0.1.0 | Android, iOS |
|
|
1292
|
+
| **`location`** | <code>string</code> | | | 0.1.0 | Android, iOS |
|
|
1293
|
+
| **`recurrence`** | <code><a href="#eventrecurrencerule">EventRecurrenceRule</a></code> | Rules for creating a recurring event. | | 7.3.0 | Android, iOS |
|
|
1294
|
+
| **`organizer`** | <code>string</code> | Email of the event organizer. | | 7.1.0 | Android |
|
|
1295
|
+
| **`span`** | <code><a href="#eventspan">EventSpan</a></code> | The span of modifications. | <code>EventSpan.THIS_EVENT</code> | | iOS |
|
|
1296
|
+
| **`startDate`** | <code>number</code> | | | 0.1.0 | Android, iOS |
|
|
1297
|
+
| **`title`** | <code>string</code> | | | 0.4.0 | Android, iOS |
|
|
1298
|
+
| **`url`** | <code>string</code> | | | 0.1.0 | iOS |
|
|
1257
1299
|
|
|
1258
1300
|
#### DeleteEventsByIdResult
|
|
1259
1301
|
|
|
@@ -1272,25 +1314,25 @@ Options for {@link CalendarAccess#requestPermission}.
|
|
|
1272
1314
|
|
|
1273
1315
|
#### DeleteEventOptions
|
|
1274
1316
|
|
|
1275
|
-
| Prop | Type | Description
|
|
1276
|
-
| ------------------ | ----------------------------------------------- |
|
|
1277
|
-
| **`commit`** | <code>boolean</code> | Whether to save the deletion to the event store immediately. Pass `false` to batch multiple changes and commit them together using `CapacitorCalendar.commit()`, which is more efficient than committing each save individually.
|
|
1278
|
-
| **`id`** | <code>string</code> | The ID of the event to delete.
|
|
1279
|
-
| **`instanceDate`** | <code>number</code> | The start time of the occurrence to delete, in milliseconds since the epoch. Use `startDate` from `listEventsInRange`. On Android, required for `THIS_EVENT` on recurring events. If omitted with `THIS_AND_FUTURE_EVENTS`, the whole series is deleted. | | 8.3.0 | Android
|
|
1280
|
-
| **`span`** | <code><a href="#eventspan">EventSpan</a></code> | How much of a recurring series to delete.
|
|
1317
|
+
| Prop | Type | Description | Default | Since | Platform |
|
|
1318
|
+
| ------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ----- | ------------ |
|
|
1319
|
+
| **`commit`** | <code>boolean</code> | Whether to save the deletion to the event store immediately. Pass `false` to batch multiple changes and commit them together using `CapacitorCalendar.commit()`, which is more efficient than committing each save individually. | <code>true</code> | 8.3.0 | iOS |
|
|
1320
|
+
| **`id`** | <code>string</code> | The ID of the event to delete. | | 7.1.0 | Android, iOS |
|
|
1321
|
+
| **`instanceDate`** | <code>number</code> | The start time of the occurrence to delete, in milliseconds since the epoch. Use `startDate` from `listEventsInRange`. On Android, required for `THIS_EVENT` on recurring events. If omitted with `THIS_AND_FUTURE_EVENTS`, the whole series is deleted. On iOS, optional since 8.11.0. If omitted, the first occurrence of the series is the target. | | 8.3.0 | Android, iOS |
|
|
1322
|
+
| **`span`** | <code><a href="#eventspan">EventSpan</a></code> | How much of a recurring series to delete. | <code>EventSpan.THIS_EVENT</code> | 7.1.0 | Android, iOS |
|
|
1281
1323
|
|
|
1282
1324
|
#### DeleteEventWithPromptOptions
|
|
1283
1325
|
|
|
1284
|
-
| Prop | Type | Description
|
|
1285
|
-
| ----------------------- | ----------------------------------------------- |
|
|
1286
|
-
| **`cancelButtonText`** | <code>string</code> | Text to show on the cancel button.
|
|
1287
|
-
| **`commit`** | <code>boolean</code> | Whether to save the deletion to the event store immediately. Pass `false` to batch multiple changes and commit them together using `CapacitorCalendar.commit()`, which is more efficient than committing each save individually.
|
|
1288
|
-
| **`confirmButtonText`** | <code>string</code> | Text to show on the confirm button.
|
|
1289
|
-
| **`id`** | <code>string</code> | The ID of the event to delete.
|
|
1290
|
-
| **`instanceDate`** | <code>number</code> | The start time of the occurrence to delete, in milliseconds since the epoch. Use `startDate` from `listEventsInRange`. On Android, required for `THIS_EVENT` on recurring events. If omitted with `THIS_AND_FUTURE_EVENTS`, the whole series is deleted. | | 8.3.0 | Android
|
|
1291
|
-
| **`message`** | <code>string</code> | Message of the dialog.
|
|
1292
|
-
| **`span`** | <code><a href="#eventspan">EventSpan</a></code> | How much of a recurring series to delete.
|
|
1293
|
-
| **`title`** | <code>string</code> | Title of the dialog.
|
|
1326
|
+
| Prop | Type | Description | Default | Since | Platform |
|
|
1327
|
+
| ----------------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ----- | ------------ |
|
|
1328
|
+
| **`cancelButtonText`** | <code>string</code> | Text to show on the cancel button. | <code>'Cancel'</code> | 7.1.0 | Android, iOS |
|
|
1329
|
+
| **`commit`** | <code>boolean</code> | Whether to save the deletion to the event store immediately. Pass `false` to batch multiple changes and commit them together using `CapacitorCalendar.commit()`, which is more efficient than committing each save individually. | <code>true</code> | 8.3.0 | iOS |
|
|
1330
|
+
| **`confirmButtonText`** | <code>string</code> | Text to show on the confirm button. | <code>'Delete'</code> | 7.1.0 | Android, iOS |
|
|
1331
|
+
| **`id`** | <code>string</code> | The ID of the event to delete. | | 7.1.0 | Android, iOS |
|
|
1332
|
+
| **`instanceDate`** | <code>number</code> | The start time of the occurrence to delete, in milliseconds since the epoch. Use `startDate` from `listEventsInRange`. On Android, required for `THIS_EVENT` on recurring events. If omitted with `THIS_AND_FUTURE_EVENTS`, the whole series is deleted. On iOS, optional since 8.11.0. If omitted, the first occurrence of the series is the target. | | 8.3.0 | Android, iOS |
|
|
1333
|
+
| **`message`** | <code>string</code> | Message of the dialog. | | 7.1.0 | Android, iOS |
|
|
1334
|
+
| **`span`** | <code><a href="#eventspan">EventSpan</a></code> | How much of a recurring series to delete. | <code>EventSpan.THIS_EVENT</code> | 7.1.0 | Android, iOS |
|
|
1335
|
+
| **`title`** | <code>string</code> | Title of the dialog. | | 7.1.0 | Android, iOS |
|
|
1294
1336
|
|
|
1295
1337
|
#### ListEventsInRangeResult
|
|
1296
1338
|
|
|
@@ -1330,10 +1372,23 @@ Options for {@link CalendarAccess#requestPermission}.
|
|
|
1330
1372
|
|
|
1331
1373
|
#### ListEventsInRangeOptions
|
|
1332
1374
|
|
|
1333
|
-
| Prop
|
|
1334
|
-
|
|
|
1335
|
-
| **`from`**
|
|
1336
|
-
| **`to`**
|
|
1375
|
+
| Prop | Type | Description | Since |
|
|
1376
|
+
| ----------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
|
|
1377
|
+
| **`from`** | <code>number</code> | The start of the range, in milliseconds since the epoch. Events still in progress at this time are included. | 7.1.0 |
|
|
1378
|
+
| **`to`** | <code>number</code> | The end of the range, in milliseconds since the epoch. Events that begin at or after this time are typically excluded; prefer the next day's start when querying a single calendar day. | 7.1.0 |
|
|
1379
|
+
| **`calendarIds`** | <code>string[]</code> | Ids of the calendars to search. When omitted or empty, all calendars are searched. Rejects if an id does not match a calendar. | 8.11.0 |
|
|
1380
|
+
|
|
1381
|
+
#### GetEventByIdResult
|
|
1382
|
+
|
|
1383
|
+
| Prop | Type | Description | Since | Platform |
|
|
1384
|
+
| ----------- | --------------------------------------------------------------- | ------------------------------------------------------- | ------ | ------------ |
|
|
1385
|
+
| **`event`** | <code><a href="#calendarevent">CalendarEvent</a> \| null</code> | The event for the given id, or `null` when none exists. | 8.11.0 | Android, iOS |
|
|
1386
|
+
|
|
1387
|
+
#### GetEventByIdOptions
|
|
1388
|
+
|
|
1389
|
+
| Prop | Type | Description | Since |
|
|
1390
|
+
| -------- | ------------------- | ------------- | ------ |
|
|
1391
|
+
| **`id`** | <code>string</code> | The event id. | 8.11.0 |
|
|
1337
1392
|
|
|
1338
1393
|
#### SelectCalendarsWithPromptResult
|
|
1339
1394
|
|
|
@@ -1351,7 +1406,7 @@ Options for {@link CalendarAccess#requestPermission}.
|
|
|
1351
1406
|
| **`color`** | <code>string \| null</code> | Hex color string, or null when none is available. Format: `#RRGGBB` when opaque; `#RRGGBBAA` when alpha is below fully opaque. | 7.1.0 | Android, iOS |
|
|
1352
1407
|
| **`colorName`** | <code><a href="#systemcolorname">SystemColorName</a> \| null</code> | Named color if the stored color matches one of the system colors; otherwise null. May be null in dark mode or for custom hex. Always null on Android. | 8.8.0 | Android, iOS |
|
|
1353
1408
|
| **`isImmutable`** | <code>boolean \| null</code> | | 7.1.0 | iOS |
|
|
1354
|
-
| **`allowsContentModifications`** | <code>boolean \| null</code> |
|
|
1409
|
+
| **`allowsContentModifications`** | <code>boolean \| null</code> | Whether events can be added to or changed in this calendar. | 7.1.0 | Android, iOS |
|
|
1355
1410
|
| **`type`** | <code><a href="#calendartype">CalendarType</a> \| null</code> | | 7.1.0 | iOS |
|
|
1356
1411
|
| **`isSubscribed`** | <code>boolean \| null</code> | | 7.1.0 | iOS |
|
|
1357
1412
|
| **`source`** | <code><a href="#calendarsource">CalendarSource</a> \| null</code> | | 7.1.0 | iOS |
|
|
@@ -20,6 +20,7 @@ import dev.barooni.capacitor.calendar.models.inputs.DeleteEventInput
|
|
|
20
20
|
import dev.barooni.capacitor.calendar.models.inputs.DeleteEventWithPromptInput
|
|
21
21
|
import dev.barooni.capacitor.calendar.models.inputs.DeleteEventsByIdInput
|
|
22
22
|
import dev.barooni.capacitor.calendar.models.inputs.GetDefaultCalendarInput
|
|
23
|
+
import dev.barooni.capacitor.calendar.models.inputs.GetEventByIdInput
|
|
23
24
|
import dev.barooni.capacitor.calendar.models.inputs.ListEventsInRangeInput
|
|
24
25
|
import dev.barooni.capacitor.calendar.models.inputs.ModifyCalendarInput
|
|
25
26
|
import dev.barooni.capacitor.calendar.models.inputs.ModifyEvent
|
|
@@ -33,6 +34,7 @@ import dev.barooni.capacitor.calendar.models.results.RequestAllPermissionsResult
|
|
|
33
34
|
import dev.barooni.capacitor.calendar.models.results.RequestPermissionResult
|
|
34
35
|
import dev.barooni.capacitor.calendar.models.templates.JSResult
|
|
35
36
|
import dev.barooni.capacitor.calendar.utils.DeclarationCheck
|
|
37
|
+
import dev.barooni.capacitor.calendar.utils.PluginCallRejecter
|
|
36
38
|
|
|
37
39
|
@CapacitorPlugin(
|
|
38
40
|
name = "CapacitorCalendar",
|
|
@@ -490,6 +492,23 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
490
492
|
}
|
|
491
493
|
}
|
|
492
494
|
|
|
495
|
+
@PluginMethod(returnType = PluginMethod.RETURN_PROMISE)
|
|
496
|
+
fun getEventById(call: PluginCall) {
|
|
497
|
+
try {
|
|
498
|
+
declarationCheck.ensureManifestPermissions(Manifest.permission.READ_CALENDAR)
|
|
499
|
+
val input = GetEventByIdInput(call)
|
|
500
|
+
implementation.getEventById(input) { result, error ->
|
|
501
|
+
if (error != null) {
|
|
502
|
+
rejectCall(call, error)
|
|
503
|
+
return@getEventById
|
|
504
|
+
}
|
|
505
|
+
resolveCall(call, result)
|
|
506
|
+
}
|
|
507
|
+
} catch (error: Exception) {
|
|
508
|
+
rejectCall(call, error)
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
493
512
|
@PluginMethod
|
|
494
513
|
fun modifyCalendar(call: PluginCall) {
|
|
495
514
|
try {
|
|
@@ -517,10 +536,7 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
517
536
|
call: PluginCall,
|
|
518
537
|
error: Exception?,
|
|
519
538
|
) {
|
|
520
|
-
|
|
521
|
-
error?.message
|
|
522
|
-
?: PluginError.CustomError("An unknown error has occurred.").message
|
|
523
|
-
call.reject(message, (error as? PluginError)?.code)
|
|
539
|
+
PluginCallRejecter.reject(call, error)
|
|
524
540
|
}
|
|
525
541
|
|
|
526
542
|
private fun resolveCall(call: PluginCall) {
|
|
@@ -4,45 +4,54 @@ sealed class PluginError(
|
|
|
4
4
|
localizedDescription: String,
|
|
5
5
|
val code: String? = null,
|
|
6
6
|
) : Exception(localizedDescription) {
|
|
7
|
-
data object AccountNameMissing : PluginError("Account name must be provided.")
|
|
7
|
+
data object AccountNameMissing : PluginError("Account name must be provided.", "EB-CLDR-0001")
|
|
8
8
|
|
|
9
|
-
data object AttendeeEmailMissing : PluginError("Attendee email must be provided.")
|
|
9
|
+
data object AttendeeEmailMissing : PluginError("Attendee email must be provided.", "EB-CLDR-0001")
|
|
10
10
|
|
|
11
|
-
data object CalendarIdMissing : PluginError("Calendar ID must be provided.")
|
|
11
|
+
data object CalendarIdMissing : PluginError("Calendar ID must be provided.", "EB-CLDR-0001")
|
|
12
12
|
|
|
13
|
-
data object CalendarNotFound : PluginError("Calendar not found.")
|
|
13
|
+
data object CalendarNotFound : PluginError("Calendar not found.", "EB-CLDR-0002")
|
|
14
14
|
|
|
15
|
-
data object ColorMissing : PluginError("Color must be provided.")
|
|
15
|
+
data object ColorMissing : PluginError("Color must be provided.", "EB-CLDR-0001")
|
|
16
16
|
|
|
17
17
|
data class CustomError(
|
|
18
18
|
val details: String,
|
|
19
19
|
) : PluginError(details)
|
|
20
20
|
|
|
21
|
-
data object EventNotFound : PluginError("Event not found.")
|
|
21
|
+
data object EventNotFound : PluginError("Event not found.", "EB-CLDR-0002")
|
|
22
22
|
|
|
23
|
-
data object FailedToDelete : PluginError("Failed to delete.")
|
|
23
|
+
data object FailedToDelete : PluginError("Failed to delete.", "EB-CLDR-0004")
|
|
24
24
|
|
|
25
|
-
data object FailedToModify : PluginError("Failed to modify.")
|
|
25
|
+
data object FailedToModify : PluginError("Failed to modify.", "EB-CLDR-0004")
|
|
26
26
|
|
|
27
|
-
data object FailedToRetrieveCalendarId : PluginError("Failed to retrieve calendar ID.")
|
|
27
|
+
data object FailedToRetrieveCalendarId : PluginError("Failed to retrieve calendar ID.", "EB-CLDR-0004")
|
|
28
28
|
|
|
29
|
-
data object FailedToRetrieveEventId : PluginError("Failed to retrieve event ID.")
|
|
29
|
+
data object FailedToRetrieveEventId : PluginError("Failed to retrieve event ID.", "EB-CLDR-0004")
|
|
30
30
|
|
|
31
|
-
data object FromDateMissing : PluginError("From date must be provided.")
|
|
31
|
+
data object FromDateMissing : PluginError("From date must be provided.", "EB-CLDR-0001")
|
|
32
32
|
|
|
33
33
|
data object InstanceDateMissing : PluginError(
|
|
34
34
|
"Instance date must be provided for this span on recurring events.",
|
|
35
|
+
"EB-CLDR-0001",
|
|
35
36
|
)
|
|
36
37
|
|
|
37
|
-
data
|
|
38
|
+
data class IoError(
|
|
39
|
+
val details: String,
|
|
40
|
+
) : PluginError(details, "EB-CLDR-0004")
|
|
41
|
+
|
|
42
|
+
data object InvalidCalendarId : PluginError("Invalid calendar ID.", "EB-CLDR-0001")
|
|
43
|
+
|
|
44
|
+
data object InvalidColor : PluginError("Invalid color format.", "EB-CLDR-0001")
|
|
38
45
|
|
|
39
|
-
data object
|
|
46
|
+
data object InvalidEventId : PluginError("Invalid event ID.", "EB-CLDR-0001")
|
|
40
47
|
|
|
41
|
-
data object
|
|
48
|
+
data object InvalidFrequency : PluginError("Invalid frequency.", "EB-CLDR-0001")
|
|
42
49
|
|
|
43
|
-
data object
|
|
50
|
+
data object InvalidInvitees : PluginError("Invalid invitees. Array must contain only strings.", "EB-CLDR-0001")
|
|
44
51
|
|
|
45
|
-
data object
|
|
52
|
+
data object InvalidScope : PluginError("Invalid scope.", "EB-CLDR-0001")
|
|
53
|
+
|
|
54
|
+
data object MessageMissing : PluginError("Message must be provided.", "EB-CLDR-0001")
|
|
46
55
|
|
|
47
56
|
data class MissingDeclaration(
|
|
48
57
|
val permission: String,
|
|
@@ -51,19 +60,29 @@ sealed class PluginError(
|
|
|
51
60
|
"EB-CLDR-0100",
|
|
52
61
|
)
|
|
53
62
|
|
|
54
|
-
data object
|
|
63
|
+
data object MissingFrequency : PluginError("Frequency must be provided.", "EB-CLDR-0001")
|
|
64
|
+
|
|
65
|
+
data object MissingId : PluginError("Event ID must be provided.", "EB-CLDR-0001")
|
|
55
66
|
|
|
56
|
-
data object MissingScope : PluginError("Scope must be provided.")
|
|
67
|
+
data object MissingScope : PluginError("Scope must be provided.", "EB-CLDR-0001")
|
|
57
68
|
|
|
58
69
|
data object NoCalendarsAvailable : PluginError("No calendars available.")
|
|
59
70
|
|
|
60
|
-
data object NoFieldsToModify : PluginError("At least one of title or color must be provided.")
|
|
71
|
+
data object NoFieldsToModify : PluginError("At least one of title or color must be provided.", "EB-CLDR-0001")
|
|
61
72
|
|
|
62
|
-
data
|
|
73
|
+
data class NotSupported(
|
|
74
|
+
val details: String,
|
|
75
|
+
) : PluginError(details, "EB-CLDR-0005")
|
|
76
|
+
|
|
77
|
+
data object OwnerAccountMissing : PluginError("Owner account must be provided.", "EB-CLDR-0001")
|
|
78
|
+
|
|
79
|
+
data class PermissionDenied(
|
|
80
|
+
val details: String,
|
|
81
|
+
) : PluginError(details, "EB-CLDR-0020")
|
|
63
82
|
|
|
64
|
-
data object TitleMissing : PluginError("Title must be provided.")
|
|
83
|
+
data object TitleMissing : PluginError("Title must be provided.", "EB-CLDR-0001")
|
|
65
84
|
|
|
66
|
-
data object ToDateMissing : PluginError("To date must be provided.")
|
|
85
|
+
data object ToDateMissing : PluginError("To date must be provided.", "EB-CLDR-0001")
|
|
67
86
|
|
|
68
87
|
data object UnhandledPermissionState : PluginError("Unhandled permission state.")
|
|
69
88
|
|