@ebarooni/capacitor-calendar 8.6.0 → 8.7.1

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.
Files changed (49) hide show
  1. package/README.md +164 -99
  2. package/android/src/main/java/dev/barooni/capacitor/calendar/PluginError.kt +2 -0
  3. package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt +54 -5
  4. package/android/src/main/java/dev/barooni/capacitor/calendar/utils/ImplementationHelper.kt +80 -0
  5. package/dist/docs.json +287 -80
  6. package/dist/esm/index.d.ts +5 -2
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/esm/schemas/enums/reminder-recurrence-frequency.d.ts +5 -5
  9. package/dist/esm/schemas/enums/reminder-recurrence-frequency.js +5 -5
  10. package/dist/esm/schemas/enums/reminder-recurrence-frequency.js.map +1 -1
  11. package/dist/esm/schemas/interfaces/create-reminder-options.d.ts +39 -20
  12. package/dist/esm/schemas/interfaces/create-reminder-options.js.map +1 -1
  13. package/dist/esm/schemas/interfaces/create-reminder-result.d.ts +12 -0
  14. package/dist/esm/schemas/interfaces/create-reminder-result.js +2 -0
  15. package/dist/esm/schemas/interfaces/create-reminder-result.js.map +1 -0
  16. package/dist/esm/schemas/interfaces/delete-reminder-options.d.ts +10 -0
  17. package/dist/esm/schemas/interfaces/delete-reminder-options.js.map +1 -1
  18. package/dist/esm/schemas/interfaces/delete-reminders-by-id-result.d.ts +13 -0
  19. package/dist/esm/schemas/interfaces/delete-reminders-by-id-result.js +2 -0
  20. package/dist/esm/schemas/interfaces/delete-reminders-by-id-result.js.map +1 -0
  21. package/dist/esm/schemas/interfaces/get-reminder-by-id-result.d.ts +13 -0
  22. package/dist/esm/schemas/interfaces/get-reminder-by-id-result.js +2 -0
  23. package/dist/esm/schemas/interfaces/get-reminder-by-id-result.js.map +1 -0
  24. package/dist/esm/schemas/interfaces/get-reminders-from-lists-result.d.ts +13 -0
  25. package/dist/esm/schemas/interfaces/get-reminders-from-lists-result.js +2 -0
  26. package/dist/esm/schemas/interfaces/get-reminders-from-lists-result.js.map +1 -0
  27. package/dist/esm/schemas/interfaces/modify-reminder-options.d.ts +72 -22
  28. package/dist/esm/schemas/interfaces/modify-reminder-options.js.map +1 -1
  29. package/dist/esm/schemas/interfaces/recurrence-rule.d.ts +7 -1
  30. package/dist/esm/schemas/interfaces/recurrence-rule.js.map +1 -1
  31. package/dist/esm/schemas/interfaces/reminder.d.ts +1 -0
  32. package/dist/esm/schemas/interfaces/reminder.js.map +1 -1
  33. package/dist/esm/sub-definitions/reminders-operations.d.ts +7 -23
  34. package/dist/esm/sub-definitions/reminders-operations.js.map +1 -1
  35. package/dist/esm/web.d.ts +7 -11
  36. package/dist/esm/web.js.map +1 -1
  37. package/dist/plugin.cjs.js +5 -5
  38. package/dist/plugin.cjs.js.map +1 -1
  39. package/dist/plugin.js +5 -5
  40. package/dist/plugin.js.map +1 -1
  41. package/ios/Plugin/Implementation/CapacitorCalendar.swift +39 -21
  42. package/ios/Plugin/Models/Inputs/CreateEventWithPromptInput.swift +3 -3
  43. package/ios/Plugin/Models/Inputs/CreateReminderInput.swift +14 -4
  44. package/ios/Plugin/Models/Inputs/DeleteReminderInput.swift +7 -1
  45. package/ios/Plugin/Models/Inputs/ModifyReminderInput.swift +66 -5
  46. package/ios/Plugin/Models/Structs/RecurrenceInput.swift +10 -0
  47. package/ios/Plugin/PluginError.swift +3 -0
  48. package/ios/Plugin/Utils/ImplementationHelper.swift +27 -7
  49. package/package.json +2 -2
package/README.md CHANGED
@@ -21,34 +21,56 @@
21
21
 
22
22
  ![capacitor-calendar-logo](assets/images/text-logo.png)
23
23
 
24
- Full-featured Capacitor plugin for calendar and reminders access on iOS, Android, and the web. On iOS and Android, manage permissions, create, modify, and delete events and reminders programmatically or via the native UI, query events in a date range, and list available calendars. On the web, create events as ICS files that users can add to their calendar.
24
+ `@ebarooni/capacitor-calendar` connects your Capacitor app to the native calendar. On iOS and Android, create, edit, and list events, and manage calendars and permissions. iOS also supports reminders. On the web, the plugin builds a downloadable `.ics` file; it does not write to a device calendar.
25
25
 
26
- ## Core Features
26
+ ## Table of Contents
27
27
 
28
- - ✅ **Events** – Create, update, delete, and list events in a date range
29
- - ✅ **Native Prompts** – Built-in system dialogs for creating, editing, and deleting events
30
- - ✅ **Permissions** – Granular control (full access, write-only, read-only)
31
- - ✅ **Calendars** – List calendars, get default, create, modify, and delete custom calendars
32
- - ✅ **Open Calendar App** – Launch the native Calendar app directly
33
- - 📅 **Reminders** – Full create, read, update, delete support _(iOS only)_
34
- - 🔍 **Advanced iOS Features** – Calendar sources, calendar selection prompts, default reminders list
28
+ - [Features and Platforms](#features-and-platforms)
29
+ - [Demo](#demo)
30
+ - [Why this plugin?](#why-this-plugin)
31
+ - [MCP Server](#mcp-server)
32
+ - [Installation](#installation)
33
+ - [Setup](#setup)
34
+ - [Quick Start](#quick-start)
35
+ - [Usage Examples](#usage-examples)
36
+ - [Documentation](#documentation)
37
+ - [Changelog](#changelog)
38
+ - [Breaking Changes](#breaking-changes)
39
+ - [API](#api)
40
+ - [Contributing](#contributing)
41
+ - [License](#license)
42
+
43
+ ## Features and Platforms
44
+
45
+ | Capability | iOS | Android | Web |
46
+ | :------------------------------------------------ | :-: | :-----: | :-----------: |
47
+ | Create, update, and delete events | ✅ | ✅ | Create only\* |
48
+ | Native prompts to create, edit, and delete events | ✅ | ✅ | – |
49
+ | List events in a date range | ✅ | ✅ | – |
50
+ | Request calendar permissions | ✅ | ✅ | – |
51
+ | List, create, modify, and delete calendars | ✅ | ✅ | – |
52
+ | Open the native Calendar app | ✅ | ✅ | – |
53
+ | Calendar sources and a calendar picker prompt | ✅ | – | – |
54
+ | Reminders and reminder lists | ✅ | – | – |
35
55
 
36
- ## Supported Platforms
56
+ \* On the web, `createEvent` returns a downloadable `.ics` file. It does not write to a device calendar. See [Create and download an event on the web](#create-and-download-an-event-on-the-web).
37
57
 
38
- - **iOS** — Full support (including Reminders and advanced features)
39
- - **Android** — Strong support for all core calendar features
40
- - **Web** — Partial support (create event)
58
+ ## Demo
59
+
60
+ | iOS | Android |
61
+ | :-----------------------------: | :---------------------------------: |
62
+ | ![](./assets/demo/ios-demo.gif) | ![](./assets/demo/android-demo.gif) |
41
63
 
42
64
  ## Why this plugin?
43
65
 
44
- - **Original and established.** Available since Capacitor 5, this plugin has been around longer than the alternatives and has matured over time.
45
- - **Actively maintained by the original author.** Updates, bug fixes, and new features are driven by someone who is deeply familiar with the codebase and committed to keeping it healthy.
46
- - **Fast support.** Questions, bug reports, and integration help are handled promptly.
47
- - **Reduced vendor risk.** Relying on a single plugin provider for all your needs is a liability. Choosing specialized, independent maintainers keeps your stack resilient.
66
+ - **Established.** Available since Capacitor 5, with years of real-world use behind it.
67
+ - **Actively maintained.** The original author still owns the codebase and ships fixes and features.
68
+ - **Fast support.** Questions and bug reports get quick answers.
69
+ - **Lower vendor risk.** Relying on one plugin author for everything is risky. Independent, focused maintainers keep your stack resilient.
48
70
 
49
71
  ## MCP Server
50
72
 
51
- `@ebarooni/capacitor-calendar` ships an official [MCP](https://modelcontextprotocol.io) server so AI coding assistants can work with the plugin accurately.
73
+ `@ebarooni/capacitor-calendar` ships an official [MCP](https://modelcontextprotocol.io) server. It gives AI coding assistants accurate, grounded knowledge of the plugin.
52
74
 
53
75
  ```bash
54
76
  docker run --rm -d --name capacitor-calendar-mcp -p 8080:8080 ghcr.io/ebarooni/capacitor-calendar-mcp:1.1.0
@@ -56,19 +78,6 @@ docker run --rm -d --name capacitor-calendar-mcp -p 8080:8080 ghcr.io/ebarooni/c
56
78
 
57
79
  See [`mcp/README.md`](mcp/README.md) for client configuration and full details.
58
80
 
59
- ## Table of Contents
60
-
61
- - [Installation](#installation)
62
- - [Demo](#demo)
63
- - [Setup](#setup)
64
- - [Quick Start](#quick-start)
65
- - [Usage Examples](#usage-examples)
66
- - [Documentation](#documentation)
67
- - [Changelog](#changelog)
68
- - [API](#api)
69
- - [Contributing](#contributing)
70
- - [License](#license)
71
-
72
81
  ## Installation
73
82
 
74
83
  ```bash
@@ -76,15 +85,9 @@ npm install @ebarooni/capacitor-calendar
76
85
  npx cap sync
77
86
  ```
78
87
 
79
- ## Demo
80
-
81
- | iOS 26 | Android 17 |
82
- | :-----------------------------: | :---------------------------------: |
83
- | ![](./assets/demo/ios-demo.gif) | ![](./assets/demo/android-demo.gif) |
84
-
85
88
  ## Setup
86
89
 
87
- This plugin works with native calendar APIs, so you'll need to configure permissions on each platform before requesting access at runtime.
90
+ This plugin works with native calendar APIs, so you need to configure permissions on each platform before you request access at runtime. After setup, see [Quick Start](#quick-start) to request permissions in code.
88
91
 
89
92
  ### Android
90
93
 
@@ -95,7 +98,7 @@ Add these permissions to `android/app/src/main/AndroidManifest.xml`:
95
98
  <uses-permission android:name="android.permission.WRITE_CALENDAR" />
96
99
  ```
97
100
 
98
- Don't forget to request the matching runtime permissions before reading from or writing to the calendar.
101
+ Request the matching runtime permissions before you read from or write to the calendar.
99
102
 
100
103
  ### iOS
101
104
 
@@ -119,7 +122,7 @@ Add the appropriate usage description keys to `ios/App/App/Info.plist`. Starting
119
122
  ```
120
123
 
121
124
  > [!IMPORTANT]
122
- > Only include the keys your app actually needs. If you're only creating events, you can safely omit the full access and reminders entries.
125
+ > Only include the keys your app actually needs. If you only create events, you can omit the full access and reminders entries.
123
126
 
124
127
  ### Official References
125
128
 
@@ -128,7 +131,7 @@ Add the appropriate usage description keys to `ios/App/App/Info.plist`. Starting
128
131
 
129
132
  ## Quick Start
130
133
 
131
- Here's a simple example to get you up and running quickly:
134
+ The sample below is for Android and iOS. For Web, see [Create and download an event on the web](#create-and-download-an-event-on-the-web).
132
135
 
133
136
  ```typescript
134
137
  import { CapacitorCalendar } from '@ebarooni/capacitor-calendar';
@@ -159,6 +162,28 @@ console.log('Event created with ID:', id);
159
162
 
160
163
  ## Usage Examples
161
164
 
165
+ ### Create and download an event on the web
166
+
167
+ On Web, `createEvent` builds an `.ics` file. It does not write to a calendar store. Use `downloadIcsFile` to start a browser download:
168
+
169
+ ```typescript
170
+ import { CapacitorCalendar, downloadIcsFile } from '@ebarooni/capacitor-calendar';
171
+
172
+ const startDate = Date.now() + 60 * 60 * 1000;
173
+ const endDate = startDate + 60 * 60 * 1000;
174
+
175
+ const { ics } = await CapacitorCalendar.createEvent({
176
+ title: 'Team standup',
177
+ startDate,
178
+ endDate,
179
+ icsFileName: 'team-standup.ics',
180
+ });
181
+
182
+ if (ics) {
183
+ await downloadIcsFile(ics);
184
+ }
185
+ ```
186
+
162
187
  ### Open the native event editor
163
188
 
164
189
  Use the system calendar UI to let users create or edit events:
@@ -175,6 +200,21 @@ await CapacitorCalendar.createEventWithPrompt({
175
200
  > [!NOTE]
176
201
  > On Android, this method always returns null. If you need the event ID, call `listEventsInRange(...)` afterward.
177
202
 
203
+ ### Modify or delete an event
204
+
205
+ The sample below is for Android and iOS. Use an `id` from `createEvent` or `listEventsInRange`:
206
+
207
+ ```typescript
208
+ await CapacitorCalendar.modifyEvent({
209
+ id: eventId,
210
+ title: 'Updated title',
211
+ });
212
+
213
+ await CapacitorCalendar.deleteEvent({
214
+ id: eventId,
215
+ });
216
+ ```
217
+
178
218
  ### List events in a range
179
219
 
180
220
  `listEventsInRange` returns events that overlap the given range, not only events that start or end inside it. Multi-day events that span the interval are included.
@@ -244,6 +284,10 @@ The full documentation is generated from TypeScript definitions and is available
244
284
 
245
285
  See [CHANGELOG.md](CHANGELOG.md) for the latest updates and release history.
246
286
 
287
+ ## Breaking Changes
288
+
289
+ See [BREAKING.md](BREAKING.md) for breaking changes and migration steps.
290
+
247
291
  ## API
248
292
 
249
293
  <docgen-index>
@@ -893,7 +937,7 @@ Retrieves all available reminders lists.
893
937
  ### createReminder(...)
894
938
 
895
939
  ```typescript
896
- createReminder(options: CreateReminderOptions) => Promise<{ id: string; }>
940
+ createReminder(options: CreateReminderOptions) => Promise<CreateReminderResult>
897
941
  ```
898
942
 
899
943
  Creates a reminder.
@@ -902,7 +946,7 @@ Creates a reminder.
902
946
  | ------------- | ----------------------------------------------------------------------- |
903
947
  | **`options`** | <code><a href="#createreminderoptions">CreateReminderOptions</a></code> |
904
948
 
905
- **Returns:** <code>Promise&lt;{ id: string; }&gt;</code>
949
+ **Returns:** <code>Promise&lt;<a href="#createreminderresult">CreateReminderResult</a>&gt;</code>
906
950
 
907
951
  **Since:** 0.5.0
908
952
 
@@ -969,7 +1013,7 @@ Modifies a reminder.
969
1013
  ### getReminderById(...)
970
1014
 
971
1015
  ```typescript
972
- getReminderById(options: GetReminderByIdOptions) => Promise<{ result: Reminder | null; }>
1016
+ getReminderById(options: GetReminderByIdOptions) => Promise<GetReminderByIdResult>
973
1017
  ```
974
1018
 
975
1019
  Retrieve a reminder by ID.
@@ -978,7 +1022,7 @@ Retrieve a reminder by ID.
978
1022
  | ------------- | ------------------------------------------------------------------------- |
979
1023
  | **`options`** | <code><a href="#getreminderbyidoptions">GetReminderByIdOptions</a></code> |
980
1024
 
981
- **Returns:** <code>Promise&lt;{ result: <a href="#reminder">Reminder</a> | null; }&gt;</code>
1025
+ **Returns:** <code>Promise&lt;<a href="#getreminderbyidresult">GetReminderByIdResult</a>&gt;</code>
982
1026
 
983
1027
  **Since:** 7.1.0
984
1028
 
@@ -989,7 +1033,7 @@ Retrieve a reminder by ID.
989
1033
  ### getRemindersFromLists(...)
990
1034
 
991
1035
  ```typescript
992
- getRemindersFromLists(options: GetRemindersFromListsOptions) => Promise<{ result: Reminder[]; }>
1036
+ getRemindersFromLists(options: GetRemindersFromListsOptions) => Promise<GetRemindersFromListsResult>
993
1037
  ```
994
1038
 
995
1039
  Retrieves reminders from multiple lists.
@@ -998,7 +1042,7 @@ Retrieves reminders from multiple lists.
998
1042
  | ------------- | ------------------------------------------------------------------------------------- |
999
1043
  | **`options`** | <code><a href="#getremindersfromlistsoptions">GetRemindersFromListsOptions</a></code> |
1000
1044
 
1001
- **Returns:** <code>Promise&lt;{ result: Reminder[]; }&gt;</code>
1045
+ **Returns:** <code>Promise&lt;<a href="#getremindersfromlistsresult">GetRemindersFromListsResult</a>&gt;</code>
1002
1046
 
1003
1047
  **Since:** 5.3.0
1004
1048
 
@@ -1373,30 +1417,37 @@ Options for {@link CalendarAccess#requestPermission}.
1373
1417
  | **`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.2.0 | iOS |
1374
1418
  | **`id`** | <code>string</code> | Identifier of the reminders list to delete. | | 8.2.0 | iOS |
1375
1419
 
1420
+ #### CreateReminderResult
1421
+
1422
+ | Prop | Type | Description | Since | Platform |
1423
+ | -------- | ------------------- | ----------------------------------------- | ----- | -------- |
1424
+ | **`id`** | <code>string</code> | Identifier of the newly created reminder. | 0.5.0 | iOS |
1425
+
1376
1426
  #### CreateReminderOptions
1377
1427
 
1378
- | Prop | Type | Description | Since |
1379
- | -------------------- | --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
1380
- | **`title`** | <code>string</code> | | 7.1.0 |
1381
- | **`listId`** | <code>string</code> | | 7.1.0 |
1382
- | **`priority`** | <code>number</code> | | 7.1.0 |
1383
- | **`isCompleted`** | <code>boolean</code> | | 7.1.0 |
1384
- | **`startDate`** | <code>number</code> | | 7.1.0 |
1385
- | **`dueDate`** | <code>number</code> | | 7.1.0 |
1386
- | **`completionDate`** | <code>number</code> | | 7.1.0 |
1387
- | **`notes`** | <code>string</code> | | 7.1.0 |
1388
- | **`url`** | <code>string</code> | | 7.1.0 |
1389
- | **`location`** | <code>string</code> | | 7.1.0 |
1390
- | **`recurrence`** | <code><a href="#recurrencerule">RecurrenceRule</a></code> | | 7.1.0 |
1391
- | **`alerts`** | <code>number[]</code> | Alert times in minutes relative to the reminder start. Use negative numbers for alerts before the start, and positive numbers for alerts after the start. | 7.1.0 |
1428
+ | Prop | Type | Description | Default | Since | Platform |
1429
+ | -------------------- | --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ----- | -------- |
1430
+ | **`alerts`** | <code>number[]</code> | Alert times in minutes relative to the reminder start. Use negative numbers for alerts before the start, and positive numbers for alerts after the start. On iOS only 2 alerts are supported. | | 7.1.0 | |
1431
+ | **`commit`** | <code>boolean</code> | Whether to save immediately (`true`) or batch changes for later (`false`). 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.7.0 | iOS |
1432
+ | **`completionDate`** | <code>number</code> | | | 7.1.0 | |
1433
+ | **`dueDate`** | <code>number</code> | When the reminder should be completed, in milliseconds since the epoch. On iOS, if `startDate` is omitted, it is set to this value. | | 7.1.0 | |
1434
+ | **`isCompleted`** | <code>boolean</code> | | | 7.1.0 | |
1435
+ | **`listId`** | <code>string</code> | | | 7.1.0 | |
1436
+ | **`location`** | <code>string</code> | | | 7.1.0 | |
1437
+ | **`notes`** | <code>string</code> | | | 7.1.0 | |
1438
+ | **`priority`** | <code>number</code> | | | 7.1.0 | |
1439
+ | **`recurrence`** | <code><a href="#recurrencerule">RecurrenceRule</a></code> | | | 7.1.0 | iOS |
1440
+ | **`startDate`** | <code>number</code> | When the reminder starts, in milliseconds since the epoch. Relative `alerts` use this date. | | 7.1.0 | |
1441
+ | **`title`** | <code>string</code> | | | 7.1.0 | |
1442
+ | **`url`** | <code>string</code> | | | 7.1.0 | |
1392
1443
 
1393
1444
  #### RecurrenceRule
1394
1445
 
1395
- | Prop | Type | Description | Since |
1396
- | --------------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ----- |
1397
- | **`frequency`** | <code><a href="#recurrencefrequency">RecurrenceFrequency</a></code> | | 7.1.0 |
1398
- | **`interval`** | <code>number</code> | How often it repeats (e.g. 1 for every occurrence, 2 for every second occurrence). | 7.1.0 |
1399
- | **`end`** | <code>number</code> | Timestamp of when the recurrence ends. | 7.1.0 |
1446
+ | Prop | Type | Description | Since | Platform |
1447
+ | --------------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ----- | -------- |
1448
+ | **`frequency`** | <code><a href="#recurrencefrequency">RecurrenceFrequency</a></code> | How often the reminder repeats. | 7.1.0 | iOS |
1449
+ | **`interval`** | <code>number</code> | How often it repeats (e.g. 1 for every occurrence, 2 for every second occurrence). | 7.1.0 | iOS |
1450
+ | **`end`** | <code>number</code> | End of the recurrence series as a Unix timestamp in milliseconds. | 7.1.0 | iOS |
1400
1451
 
1401
1452
  #### DeleteRemindersByIdResult
1402
1453
 
@@ -1413,45 +1464,53 @@ Options for {@link CalendarAccess#requestPermission}.
1413
1464
 
1414
1465
  #### DeleteReminderOptions
1415
1466
 
1416
- | Prop | Type | Since |
1417
- | -------- | ------------------- | ----- |
1418
- | **`id`** | <code>string</code> | 7.1.0 |
1467
+ | Prop | Type | Description | Default | Since | Platform |
1468
+ | ------------ | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ----- | -------- |
1469
+ | **`commit`** | <code>boolean</code> | Whether to save immediately (`true`) or batch changes for later (`false`). 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.7.0 | iOS |
1470
+ | **`id`** | <code>string</code> | | | 7.1.0 | |
1419
1471
 
1420
1472
  #### ModifyReminderOptions
1421
1473
 
1422
- | Prop | Type | Description | Since |
1423
- | -------------------- | --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
1424
- | **`id`** | <code>string</code> | | 7.1.0 |
1425
- | **`title`** | <code>string</code> | | 7.1.0 |
1426
- | **`listId`** | <code>string</code> | | 7.1.0 |
1427
- | **`priority`** | <code>number</code> | | 7.1.0 |
1428
- | **`isCompleted`** | <code>boolean</code> | | 7.1.0 |
1429
- | **`startDate`** | <code>number</code> | | 7.1.0 |
1430
- | **`dueDate`** | <code>number</code> | | 7.1.0 |
1431
- | **`completionDate`** | <code>number</code> | | 7.1.0 |
1432
- | **`notes`** | <code>string</code> | | 7.1.0 |
1433
- | **`url`** | <code>string</code> | | 7.1.0 |
1434
- | **`location`** | <code>string</code> | | 7.1.0 |
1435
- | **`recurrence`** | <code><a href="#recurrencerule">RecurrenceRule</a></code> | | 7.1.0 |
1436
- | **`alerts`** | <code>number[]</code> | Alert times in minutes relative to the reminder start. Use negative numbers for alerts before the start, and positive numbers for alerts after the start. On iOS only 2 alerts are supported. | 7.1.0 |
1474
+ | Prop | Type | Description | Default | Since | Platform |
1475
+ | -------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | ----- | -------- |
1476
+ | **`alerts`** | <code>number[] \| null</code> | Alert times in minutes relative to the reminder start. Use negative numbers for alerts before the start, and positive numbers for alerts after the start. Omit or pass `undefined` to leave existing alerts unchanged. Pass `null` or an empty array `[]` to clear alerts. On iOS, when both `startDate` and `dueDate` are cleared in the same call, alerts are cleared even if `alerts` is set. When clearing dates across separate batched calls, pass `alerts: null` or `[]` explicitly. On iOS only 2 alerts are supported. | | 7.1.0 | |
1477
+ | **`commit`** | <code>boolean</code> | Whether to save immediately (`true`) or batch changes for later (`false`). 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.7.0 | iOS |
1478
+ | **`completionDate`** | <code>number \| null</code> | When the reminder was completed, in milliseconds since the epoch. Omit or pass `undefined` to leave the existing value unchanged. Since 8.7.0, pass `null` to clear. Clearing this date does not mark the reminder incomplete; set `isCompleted` to `false` for that. | | 7.1.0 | |
1479
+ | **`dueDate`** | <code>number \| null</code> | When the reminder is due, in milliseconds since the epoch. On iOS, if `startDate` is omitted and the reminder has no start, it is set to this value. Omit or pass `undefined` to leave the existing value unchanged. Since 8.7.0, pass `null` to clear. Clearing only `dueDate` leaves an existing start unchanged (including a start previously copied from due). Pass `startDate: null` together with `dueDate: null` to remove scheduling. | | 7.1.0 | |
1480
+ | **`id`** | <code>string</code> | | | 7.1.0 | |
1481
+ | **`isCompleted`** | <code>boolean</code> | | | 7.1.0 | |
1482
+ | **`listId`** | <code>string</code> | | | 7.1.0 | |
1483
+ | **`location`** | <code>string \| null</code> | Location for the reminder. Omit or pass `undefined` to leave the existing value unchanged. Since 8.7.0, pass `null` to clear. | | 7.1.0 | |
1484
+ | **`notes`** | <code>string \| null</code> | Notes for the reminder. Omit or pass `undefined` to leave the existing value unchanged. Since 8.7.0, pass `null` to clear. | | 7.1.0 | |
1485
+ | **`priority`** | <code>number</code> | | | 7.1.0 | |
1486
+ | **`recurrence`** | <code><a href="#recurrencerule">RecurrenceRule</a> \| null</code> | Recurrence rule for the reminder. Omit or pass `undefined` to leave the existing value unchanged. Since 8.7.0, pass `null` to clear. | | 7.1.0 | iOS |
1487
+ | **`startDate`** | <code>number \| null</code> | When the reminder starts, in milliseconds since the epoch. Relative `alerts` use this date. Omit or pass `undefined` to leave the existing value unchanged. Since 8.7.0, pass `null` to clear. If a due date remains, clearing start sets start to the due date (it does not keep the previous start). Pass `dueDate: null` as well to remove scheduling. | | 7.1.0 | |
1488
+ | **`title`** | <code>string</code> | | | 7.1.0 | |
1489
+ | **`url`** | <code>string \| null</code> | URL associated with the reminder. Omit or pass `undefined` to leave the existing value unchanged. Since 8.7.0, pass `null` to clear. | | 7.1.0 | |
1490
+
1491
+ #### GetReminderByIdResult
1492
+
1493
+ | Prop | Type | Description | Since | Platform |
1494
+ | ------------ | ----------------------------------------------------- | ---------------------------------------------------------- | ----- | -------- |
1495
+ | **`result`** | <code><a href="#reminder">Reminder</a> \| null</code> | The reminder for the given id, or `null` when none exists. | 7.1.0 | iOS |
1437
1496
 
1438
1497
  #### Reminder
1439
1498
 
1440
- | Prop | Type | Since |
1441
- | -------------------- | ----------------------------- | ----- |
1442
- | **`id`** | <code>string</code> | 7.1.0 |
1443
- | **`title`** | <code>string \| null</code> | 7.1.0 |
1444
- | **`listId`** | <code>string \| null</code> | 7.1.0 |
1445
- | **`isCompleted`** | <code>boolean</code> | 7.1.0 |
1446
- | **`priority`** | <code>number \| null</code> | 7.1.0 |
1447
- | **`notes`** | <code>string \| null</code> | 7.1.0 |
1448
- | **`location`** | <code>string \| null</code> | 7.1.0 |
1449
- | **`url`** | <code>string \| null</code> | 7.1.0 |
1450
- | **`startDate`** | <code>number \| null</code> | 7.1.0 |
1451
- | **`dueDate`** | <code>number \| null</code> | 7.1.0 |
1452
- | **`completionDate`** | <code>number \| null</code> | 7.1.0 |
1453
- | **`recurrence`** | <code>RecurrenceRule[]</code> | 7.1.0 |
1454
- | **`alerts`** | <code>number[]</code> | 7.1.0 |
1499
+ | Prop | Type | Since | Platform |
1500
+ | -------------------- | ----------------------------- | ----- | -------- |
1501
+ | **`id`** | <code>string</code> | 7.1.0 | |
1502
+ | **`title`** | <code>string \| null</code> | 7.1.0 | |
1503
+ | **`listId`** | <code>string \| null</code> | 7.1.0 | |
1504
+ | **`isCompleted`** | <code>boolean</code> | 7.1.0 | |
1505
+ | **`priority`** | <code>number \| null</code> | 7.1.0 | |
1506
+ | **`notes`** | <code>string \| null</code> | 7.1.0 | |
1507
+ | **`location`** | <code>string \| null</code> | 7.1.0 | |
1508
+ | **`url`** | <code>string \| null</code> | 7.1.0 | |
1509
+ | **`startDate`** | <code>number \| null</code> | 7.1.0 | |
1510
+ | **`dueDate`** | <code>number \| null</code> | 7.1.0 | |
1511
+ | **`completionDate`** | <code>number \| null</code> | 7.1.0 | |
1512
+ | **`recurrence`** | <code>RecurrenceRule[]</code> | 7.1.0 | iOS |
1513
+ | **`alerts`** | <code>number[]</code> | 7.1.0 | |
1455
1514
 
1456
1515
  #### GetReminderByIdOptions
1457
1516
 
@@ -1459,6 +1518,12 @@ Options for {@link CalendarAccess#requestPermission}.
1459
1518
  | -------- | ------------------- | ----- |
1460
1519
  | **`id`** | <code>string</code> | 7.1.0 |
1461
1520
 
1521
+ #### GetRemindersFromListsResult
1522
+
1523
+ | Prop | Type | Description | Since | Platform |
1524
+ | ------------ | ----------------------- | ----------------------------------- | ----- | -------- |
1525
+ | **`result`** | <code>Reminder[]</code> | Reminders from the requested lists. | 5.3.0 | iOS |
1526
+
1462
1527
  #### GetRemindersFromListsOptions
1463
1528
 
1464
1529
  | Prop | Type | Since |
@@ -17,6 +17,8 @@ sealed class PluginError(
17
17
  val details: String,
18
18
  ) : PluginError(details)
19
19
 
20
+ data object EventNotFound : PluginError("Event not found.")
21
+
20
22
  data object FailedToDelete : PluginError("Failed to delete.")
21
23
 
22
24
  data object FailedToModify : PluginError("Failed to modify.")
@@ -87,16 +87,24 @@ class CapacitorCalendar(
87
87
  fun createEvent(input: CreateEventInput): CreateEventResult {
88
88
  val cr = plugin.context.contentResolver
89
89
  val calendarId: Long = input.calendarId ?: ImplementationHelper.getDefaultCalendarId(cr)
90
+ val isAllDay = input.isAllDay == 1
91
+ val (startDate, endDate) =
92
+ if (isAllDay) {
93
+ ImplementationHelper.normalizeAllDayTimes(input.startDate, input.endDate)
94
+ } else {
95
+ Pair(input.startDate, input.endDate)
96
+ }
97
+ val timezoneId = if (isAllDay) "UTC" else input.timezoneId
90
98
 
91
99
  val values =
92
100
  ContentValues().apply {
93
101
  put(CalendarContract.Events.TITLE, input.title)
94
102
  put(CalendarContract.Events.CALENDAR_ID, calendarId)
95
- put(CalendarContract.Events.EVENT_TIMEZONE, input.timezoneId)
103
+ put(CalendarContract.Events.EVENT_TIMEZONE, timezoneId)
96
104
  input.isAllDay?.let { put(CalendarContract.Events.ALL_DAY, it) }
97
105
  input.location?.let { put(CalendarContract.Events.EVENT_LOCATION, it) }
98
- input.startDate?.let { put(CalendarContract.Events.DTSTART, it) }
99
- input.endDate?.let { put(CalendarContract.Events.DTEND, it) }
106
+ startDate?.let { put(CalendarContract.Events.DTSTART, it) }
107
+ endDate?.let { put(CalendarContract.Events.DTEND, it) }
100
108
  input.description?.let { put(CalendarContract.Events.DESCRIPTION, it) }
101
109
  input.availability?.let { put(CalendarContract.Events.AVAILABILITY, it) }
102
110
  input.organizer?.let { put(CalendarContract.Events.ORGANIZER, it) }
@@ -113,14 +121,55 @@ class CapacitorCalendar(
113
121
 
114
122
  fun modifyEvent(input: ModifyEvent) {
115
123
  val cr = plugin.context.contentResolver
124
+ val updatingDates = input.startDate != null || input.endDate != null
125
+ val settingAllDay = input.isAllDay == 1
126
+ // Normalize when setting all-day, or when editing dates on an existing all-day event
127
+ // without re-sending isAllDay. Reading ALL_DAY fails closed (EventNotFound) so a missed
128
+ // row cannot silently skip normalization and reintroduce the wrong-day bug.
129
+ val treatAsAllDay =
130
+ when {
131
+ input.isAllDay == 1 -> true
132
+ input.isAllDay == 0 -> false
133
+ updatingDates -> ImplementationHelper.isEventAllDay(cr, input.id)
134
+ else -> false
135
+ }
136
+ // Explicit isAllDay + startDate shares create's contract (inclusive local days; omitted
137
+ // endDate → one-day exclusive DTEND). Date-only patches on an existing all-day event
138
+ // normalize only the fields the caller sent, so a start-only update cannot truncate a
139
+ // multi-day span.
140
+ val (startDate, endDate) =
141
+ when {
142
+ !treatAsAllDay -> {
143
+ Pair(input.startDate, input.endDate)
144
+ }
145
+
146
+ settingAllDay && input.startDate != null -> {
147
+ ImplementationHelper.normalizeAllDayTimes(input.startDate, input.endDate)
148
+ }
149
+
150
+ else -> {
151
+ Pair(
152
+ input.startDate?.let { ImplementationHelper.utcMidnightForLocalDay(it) },
153
+ input.endDate?.let { ImplementationHelper.exclusiveUtcEndForInclusiveLocalDay(it) },
154
+ )
155
+ }
156
+ }
157
+ val writeDefaultAllDayEnd = settingAllDay && input.startDate != null && input.endDate == null
116
158
  val values =
117
159
  ContentValues().apply {
118
160
  input.title?.let { put(CalendarContract.Events.TITLE, it) }
119
161
  input.calendarId?.let { put(CalendarContract.Events.CALENDAR_ID, it) }
120
162
  input.location?.let { put(CalendarContract.Events.EVENT_LOCATION, it) }
121
- input.startDate?.let { put(CalendarContract.Events.DTSTART, it) }
122
- input.endDate?.let { put(CalendarContract.Events.DTEND, it) }
163
+ if (input.startDate != null) {
164
+ startDate?.let { put(CalendarContract.Events.DTSTART, it) }
165
+ }
166
+ if (input.endDate != null || writeDefaultAllDayEnd) {
167
+ endDate?.let { put(CalendarContract.Events.DTEND, it) }
168
+ }
123
169
  input.isAllDay?.let { put(CalendarContract.Events.ALL_DAY, it) }
170
+ if (treatAsAllDay) {
171
+ put(CalendarContract.Events.EVENT_TIMEZONE, "UTC")
172
+ }
124
173
  input.description?.let { put(CalendarContract.Events.DESCRIPTION, it) }
125
174
  input.availability?.let { put(CalendarContract.Events.AVAILABILITY, it) }
126
175
  input.organizer?.let { put(CalendarContract.Events.ORGANIZER, it) }
@@ -26,6 +26,86 @@ class ImplementationHelper {
26
26
  timeInMillis = timestamp ?: System.currentTimeMillis()
27
27
  }
28
28
 
29
+ /**
30
+ * Maps a timestamp to UTC midnight of its local calendar day.
31
+ * Required for [CalendarContract.Events] all-day rows (`EVENT_TIMEZONE` = UTC).
32
+ */
33
+ fun utcMidnightForLocalDay(timestamp: Long): Long {
34
+ val local = Calendar.getInstance().apply { timeInMillis = timestamp }
35
+ return Calendar
36
+ .getInstance(TimeZone.getTimeZone("UTC"))
37
+ .apply {
38
+ clear()
39
+ set(
40
+ local.get(Calendar.YEAR),
41
+ local.get(Calendar.MONTH),
42
+ local.get(Calendar.DAY_OF_MONTH),
43
+ )
44
+ }.timeInMillis
45
+ }
46
+
47
+ /**
48
+ * Inclusive local-day end → exclusive UTC midnight `DTEND` for all-day rows.
49
+ */
50
+ fun exclusiveUtcEndForInclusiveLocalDay(timestamp: Long): Long =
51
+ Calendar
52
+ .getInstance(TimeZone.getTimeZone("UTC"))
53
+ .apply {
54
+ timeInMillis = utcMidnightForLocalDay(timestamp)
55
+ add(Calendar.DAY_OF_MONTH, 1)
56
+ }.timeInMillis
57
+
58
+ /**
59
+ * Plugin all-day dates use local calendar days with an inclusive end (same as iOS).
60
+ * [CalendarContract] needs UTC midnight boundaries and an exclusive `DTEND`.
61
+ * When [endDate] is omitted, uses a one-day span from [startDate].
62
+ */
63
+ fun normalizeAllDayTimes(
64
+ startDate: Long?,
65
+ endDate: Long?,
66
+ ): Pair<Long?, Long?> {
67
+ val start = startDate?.let { utcMidnightForLocalDay(it) }
68
+ val exclusiveEnd =
69
+ when {
70
+ endDate != null -> {
71
+ exclusiveUtcEndForInclusiveLocalDay(endDate)
72
+ }
73
+
74
+ start != null -> {
75
+ Calendar
76
+ .getInstance(TimeZone.getTimeZone("UTC"))
77
+ .apply {
78
+ timeInMillis = start
79
+ add(Calendar.DAY_OF_MONTH, 1)
80
+ }.timeInMillis
81
+ }
82
+
83
+ else -> {
84
+ null
85
+ }
86
+ }
87
+ return Pair(start, exclusiveEnd)
88
+ }
89
+
90
+ /**
91
+ * Reads [CalendarContract.Events.ALL_DAY] for an existing event.
92
+ * Throws [PluginError.EventNotFound] when the row is missing or unreadable,
93
+ * so callers that need the flag cannot silently skip all-day normalization.
94
+ */
95
+ fun isEventAllDay(
96
+ cr: ContentResolver,
97
+ eventId: Long,
98
+ ): Boolean {
99
+ val uri = ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, eventId)
100
+ val projection = arrayOf(CalendarContract.Events.ALL_DAY)
101
+ cr.query(uri, projection, null, null, null)?.use { cursor ->
102
+ if (cursor.moveToFirst()) {
103
+ return cursor.getInt(0) == 1
104
+ }
105
+ }
106
+ throw PluginError.EventNotFound
107
+ }
108
+
29
109
  fun jsArrayToComaSeparatedString(array: JSArray?): String? {
30
110
  val list = array?.toList<Any>() ?: return null
31
111