@ebarooni/capacitor-calendar 0.3.1 → 0.5.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 +168 -28
- package/android/build.gradle +1 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendar.kt +35 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +40 -0
- package/dist/docs.json +1100 -48
- package/dist/esm/definitions.d.ts +149 -62
- package/dist/esm/definitions.js +1 -31
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +10 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schemas/enums/calendar-chooser-display-style.d.ts +15 -0
- package/dist/esm/schemas/enums/calendar-chooser-display-style.js +17 -0
- package/dist/esm/schemas/enums/calendar-chooser-display-style.js.map +1 -0
- package/dist/esm/schemas/enums/calendar-chooser-selection-style.d.ts +15 -0
- package/dist/esm/schemas/enums/calendar-chooser-selection-style.js +17 -0
- package/dist/esm/schemas/enums/calendar-chooser-selection-style.js.map +1 -0
- package/dist/esm/schemas/enums/plugin-permission.d.ts +22 -0
- package/dist/esm/schemas/enums/plugin-permission.js +24 -0
- package/dist/esm/schemas/enums/plugin-permission.js.map +1 -0
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.d.ts +6 -0
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.js +8 -0
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.js.map +1 -0
- package/dist/esm/schemas/interfaces/calendar.d.ts +12 -0
- package/dist/esm/schemas/interfaces/calendar.js +2 -0
- package/dist/esm/schemas/interfaces/calendar.js.map +1 -0
- package/dist/esm/schemas/interfaces/plugin-permissions-map.d.ts +4 -0
- package/dist/esm/schemas/interfaces/plugin-permissions-map.js +2 -0
- package/dist/esm/schemas/interfaces/plugin-permissions-map.js.map +1 -0
- package/dist/esm/schemas/interfaces/reminder-recurrence-rule.d.ts +36 -0
- package/dist/esm/schemas/interfaces/reminder-recurrence-rule.js +2 -0
- package/dist/esm/schemas/interfaces/reminder-recurrence-rule.js.map +1 -0
- package/dist/esm/schemas/interfaces/reminders-list.d.ts +3 -0
- package/dist/esm/schemas/interfaces/reminders-list.js +2 -0
- package/dist/esm/schemas/interfaces/reminders-list.js.map +1 -0
- package/dist/esm/web.d.ts +41 -5
- package/dist/esm/web.js +12 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +58 -14
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +58 -14
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorCalendar.swift +33 -0
- package/ios/Plugin/CapacitorCalendarPlugin.m +4 -0
- package/ios/Plugin/CapacitorCalendarPlugin.swift +131 -22
- package/ios/Plugin/CapacitorReminders.swift +177 -0
- package/package.json +10 -5
- package/ios/Plugin/Calendar.swift +0 -14
package/README.md
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<h1 align="center">CapacitorCalendar</h1>
|
|
2
2
|
<p align="center">
|
|
3
3
|
<em>
|
|
4
|
-
|
|
5
|
-
With CRUD functionalities (Create, Read, Update, Delete), you can seamlessly interact with the device's native
|
|
6
|
-
calendar directly from your app.
|
|
4
|
+
The Capacitor Calendar Plugin enables full calendar functionality on iOS and Android, with added reminder support for iOS devices.
|
|
7
5
|
</em>
|
|
8
6
|
</p>
|
|
9
7
|
<p align="center">
|
|
@@ -29,10 +27,10 @@ npx cap sync
|
|
|
29
27
|
|
|
30
28
|
## Support Range
|
|
31
29
|
|
|
32
|
-
|
|
|
33
|
-
|
|
34
|
-
|
|
|
35
|
-
|
|
|
30
|
+
| Platform | range |
|
|
31
|
+
|:--------:|:-------------------------:|
|
|
32
|
+
| iOS | ≥ 13 |
|
|
33
|
+
| Android | ≥ 7 (SDK 24 or Nougat) |
|
|
36
34
|
|
|
37
35
|
## [Demo (click for details)](./example/README.md)
|
|
38
36
|
|
|
@@ -41,7 +39,9 @@ npx cap sync
|
|
|
41
39
|
|:--------------------------------------:|:------------------------------------------:|
|
|
42
40
|
|  |  |
|
|
43
41
|
|
|
44
|
-
On iOS, `readCalendar` permission is not needed when you
|
|
42
|
+
On iOS, `readCalendar` permission is not needed when you a
|
|
43
|
+
|
|
44
|
+
re creating an event using the native prompt.
|
|
45
45
|
The video is just for showing the functionality, otherwise the `createEventWithPrompt` method works without the `readCalendar` authorization.
|
|
46
46
|
|
|
47
47
|
## MVP
|
|
@@ -49,7 +49,7 @@ The video is just for showing the functionality, otherwise the `createEventWithP
|
|
|
49
49
|
- ✅ Choose calendars with prompt (only supported on iOS)
|
|
50
50
|
- ✅ Get list of available calendars
|
|
51
51
|
- ✅ Get default calendar
|
|
52
|
-
-
|
|
52
|
+
- ✅ Create calendar events without native prompts
|
|
53
53
|
- ⌛️ Create reminders (only supported on iOS)
|
|
54
54
|
- ⌛️ Find calendar events
|
|
55
55
|
- ⌛️ Delete calendar events
|
|
@@ -74,6 +74,10 @@ permissions can be found below:
|
|
|
74
74
|
* [`selectCalendarsWithPrompt(...)`](#selectcalendarswithprompt)
|
|
75
75
|
* [`listCalendars()`](#listcalendars)
|
|
76
76
|
* [`getDefaultCalendar()`](#getdefaultcalendar)
|
|
77
|
+
* [`createEvent(...)`](#createevent)
|
|
78
|
+
* [`getDefaultRemindersList()`](#getdefaultreminderslist)
|
|
79
|
+
* [`getRemindersLists()`](#getreminderslists)
|
|
80
|
+
* [`createReminder(...)`](#createreminder)
|
|
77
81
|
* [Interfaces](#interfaces)
|
|
78
82
|
* [Type Aliases](#type-aliases)
|
|
79
83
|
* [Enums](#enums)
|
|
@@ -86,14 +90,14 @@ permissions can be found below:
|
|
|
86
90
|
### checkPermission(...)
|
|
87
91
|
|
|
88
92
|
```typescript
|
|
89
|
-
checkPermission(options: { alias:
|
|
93
|
+
checkPermission(options: { alias: PluginPermission; }) => Promise<{ result: PermissionState; }>
|
|
90
94
|
```
|
|
91
95
|
|
|
92
96
|
Checks the current authorization status of a specific permission.
|
|
93
97
|
|
|
94
|
-
| Param | Type
|
|
95
|
-
| ------------- |
|
|
96
|
-
| **`options`** | <code>{ alias:
|
|
98
|
+
| Param | Type | Description |
|
|
99
|
+
| ------------- | ------------------------------------------------------------------------- | ----------------------------------------- |
|
|
100
|
+
| **`options`** | <code>{ alias: <a href="#pluginpermission">PluginPermission</a>; }</code> | An object with the name of the permission |
|
|
97
101
|
|
|
98
102
|
**Returns:** <code>Promise<{ result: <a href="#permissionstate">PermissionState</a>; }></code>
|
|
99
103
|
|
|
@@ -103,12 +107,12 @@ Checks the current authorization status of a specific permission.
|
|
|
103
107
|
### checkAllPermissions()
|
|
104
108
|
|
|
105
109
|
```typescript
|
|
106
|
-
checkAllPermissions() => Promise<
|
|
110
|
+
checkAllPermissions() => Promise<PluginPermissionsMap>
|
|
107
111
|
```
|
|
108
112
|
|
|
109
113
|
Checks the current authorization status of all the required permissions for the plugin.
|
|
110
114
|
|
|
111
|
-
**Returns:** <code>Promise<<a href="#
|
|
115
|
+
**Returns:** <code>Promise<<a href="#pluginpermissionsmap">PluginPermissionsMap</a>></code>
|
|
112
116
|
|
|
113
117
|
--------------------
|
|
114
118
|
|
|
@@ -116,15 +120,15 @@ Checks the current authorization status of all the required permissions for the
|
|
|
116
120
|
### requestPermission(...)
|
|
117
121
|
|
|
118
122
|
```typescript
|
|
119
|
-
requestPermission(options: { alias:
|
|
123
|
+
requestPermission(options: { alias: PluginPermission; }) => Promise<{ result: PermissionState; }>
|
|
120
124
|
```
|
|
121
125
|
|
|
122
126
|
Requests authorization to a specific permission, if not already granted.
|
|
123
127
|
If the permission is already granted, it will directly return the status.
|
|
124
128
|
|
|
125
|
-
| Param | Type
|
|
126
|
-
| ------------- |
|
|
127
|
-
| **`options`** | <code>{ alias:
|
|
129
|
+
| Param | Type | Description |
|
|
130
|
+
| ------------- | ------------------------------------------------------------------------- | ----------------------------------------- |
|
|
131
|
+
| **`options`** | <code>{ alias: <a href="#pluginpermission">PluginPermission</a>; }</code> | An object with the name of the permission |
|
|
128
132
|
|
|
129
133
|
**Returns:** <code>Promise<{ result: <a href="#permissionstate">PermissionState</a>; }></code>
|
|
130
134
|
|
|
@@ -134,12 +138,12 @@ If the permission is already granted, it will directly return the status.
|
|
|
134
138
|
### requestAllPermissions()
|
|
135
139
|
|
|
136
140
|
```typescript
|
|
137
|
-
requestAllPermissions() => Promise<
|
|
141
|
+
requestAllPermissions() => Promise<PluginPermissionsMap>
|
|
138
142
|
```
|
|
139
143
|
|
|
140
144
|
Requests authorization to all the required permissions for the plugin, if they have not already been granted.
|
|
141
145
|
|
|
142
|
-
**Returns:** <code>Promise<<a href="#
|
|
146
|
+
**Returns:** <code>Promise<<a href="#pluginpermissionsmap">PluginPermissionsMap</a>></code>
|
|
143
147
|
|
|
144
148
|
--------------------
|
|
145
149
|
|
|
@@ -203,17 +207,70 @@ Retrieves the default calendar set on the device.
|
|
|
203
207
|
--------------------
|
|
204
208
|
|
|
205
209
|
|
|
206
|
-
###
|
|
210
|
+
### createEvent(...)
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
createEvent(options: { title: string; calendarId?: string; location?: string; startDate?: Date; endDate?: Date; isAllDay?: boolean; }) => Promise<{ eventCreated: boolean; }>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Creates an event with the provided options.
|
|
217
|
+
|
|
218
|
+
| Param | Type | Description |
|
|
219
|
+
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
|
|
220
|
+
| **`options`** | <code>{ title: string; calendarId?: string; location?: string; startDate?: <a href="#date">Date</a>; endDate?: <a href="#date">Date</a>; isAllDay?: boolean; }</code> | - Options for creating the event. |
|
|
221
|
+
|
|
222
|
+
**Returns:** <code>Promise<{ eventCreated: boolean; }></code>
|
|
223
|
+
|
|
224
|
+
--------------------
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
### getDefaultRemindersList()
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
getDefaultRemindersList() => Promise<{ result: RemindersList; }>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Retrieves the default reminders list set on the device.
|
|
234
|
+
|
|
235
|
+
**Returns:** <code>Promise<{ result: <a href="#reminderslist">RemindersList</a>; }></code>
|
|
236
|
+
|
|
237
|
+
--------------------
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
### getRemindersLists()
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
getRemindersLists() => Promise<{ result: RemindersList[]; }>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Retrieves all available reminders lists on the device.
|
|
247
|
+
|
|
248
|
+
**Returns:** <code>Promise<{ result: RemindersList[]; }></code>
|
|
249
|
+
|
|
250
|
+
--------------------
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
### createReminder(...)
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
createReminder(options: { title: string; listId?: string; priority?: number; isCompleted?: boolean; startDate?: number; dueDate?: number; completionDate?: number; notes?: string; url?: string; location?: string; recurrence?: ReminderRecurrenceRule; }) => Promise<{ reminderCreated: boolean; }>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Creates a reminder with the provided options.
|
|
260
|
+
|
|
261
|
+
| Param | Type | Description |
|
|
262
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
|
|
263
|
+
| **`options`** | <code>{ title: string; listId?: string; priority?: number; isCompleted?: boolean; startDate?: number; dueDate?: number; completionDate?: number; notes?: string; url?: string; location?: string; recurrence?: <a href="#reminderrecurrencerule">ReminderRecurrenceRule</a>; }</code> | - Options for creating the reminder. |
|
|
207
264
|
|
|
265
|
+
**Returns:** <code>Promise<{ reminderCreated: boolean; }></code>
|
|
208
266
|
|
|
209
|
-
|
|
267
|
+
--------------------
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
### Interfaces
|
|
210
271
|
|
|
211
|
-
Describes the permission status for reading from the calendar.
|
|
212
272
|
|
|
213
|
-
|
|
214
|
-
| ------------------- | ----------------------------------------------------------- |
|
|
215
|
-
| **`readCalendar`** | <code><a href="#permissionstate">PermissionState</a></code> |
|
|
216
|
-
| **`writeCalendar`** | <code><a href="#permissionstate">PermissionState</a></code> |
|
|
273
|
+
#### PluginPermissionsMap
|
|
217
274
|
|
|
218
275
|
|
|
219
276
|
#### Calendar
|
|
@@ -226,6 +283,69 @@ Represents a calendar object with an ID and title.
|
|
|
226
283
|
| **`title`** | <code>string</code> |
|
|
227
284
|
|
|
228
285
|
|
|
286
|
+
#### Date
|
|
287
|
+
|
|
288
|
+
Enables basic storage and retrieval of dates and times.
|
|
289
|
+
|
|
290
|
+
| Method | Signature | Description |
|
|
291
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
292
|
+
| **toString** | () => string | Returns a string representation of a date. The format of the string depends on the locale. |
|
|
293
|
+
| **toDateString** | () => string | Returns a date as a string value. |
|
|
294
|
+
| **toTimeString** | () => string | Returns a time as a string value. |
|
|
295
|
+
| **toLocaleString** | () => string | Returns a value as a string value appropriate to the host environment's current locale. |
|
|
296
|
+
| **toLocaleDateString** | () => string | Returns a date as a string value appropriate to the host environment's current locale. |
|
|
297
|
+
| **toLocaleTimeString** | () => string | Returns a time as a string value appropriate to the host environment's current locale. |
|
|
298
|
+
| **valueOf** | () => number | Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. |
|
|
299
|
+
| **getTime** | () => number | Gets the time value in milliseconds. |
|
|
300
|
+
| **getFullYear** | () => number | Gets the year, using local time. |
|
|
301
|
+
| **getUTCFullYear** | () => number | Gets the year using Universal Coordinated Time (UTC). |
|
|
302
|
+
| **getMonth** | () => number | Gets the month, using local time. |
|
|
303
|
+
| **getUTCMonth** | () => number | Gets the month of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
304
|
+
| **getDate** | () => number | Gets the day-of-the-month, using local time. |
|
|
305
|
+
| **getUTCDate** | () => number | Gets the day-of-the-month, using Universal Coordinated Time (UTC). |
|
|
306
|
+
| **getDay** | () => number | Gets the day of the week, using local time. |
|
|
307
|
+
| **getUTCDay** | () => number | Gets the day of the week using Universal Coordinated Time (UTC). |
|
|
308
|
+
| **getHours** | () => number | Gets the hours in a date, using local time. |
|
|
309
|
+
| **getUTCHours** | () => number | Gets the hours value in a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
310
|
+
| **getMinutes** | () => number | Gets the minutes of a <a href="#date">Date</a> object, using local time. |
|
|
311
|
+
| **getUTCMinutes** | () => number | Gets the minutes of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
312
|
+
| **getSeconds** | () => number | Gets the seconds of a <a href="#date">Date</a> object, using local time. |
|
|
313
|
+
| **getUTCSeconds** | () => number | Gets the seconds of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
314
|
+
| **getMilliseconds** | () => number | Gets the milliseconds of a <a href="#date">Date</a>, using local time. |
|
|
315
|
+
| **getUTCMilliseconds** | () => number | Gets the milliseconds of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
316
|
+
| **getTimezoneOffset** | () => number | Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). |
|
|
317
|
+
| **setTime** | (time: number) => number | Sets the date and time value in the <a href="#date">Date</a> object. |
|
|
318
|
+
| **setMilliseconds** | (ms: number) => number | Sets the milliseconds value in the <a href="#date">Date</a> object using local time. |
|
|
319
|
+
| **setUTCMilliseconds** | (ms: number) => number | Sets the milliseconds value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
320
|
+
| **setSeconds** | (sec: number, ms?: number \| undefined) => number | Sets the seconds value in the <a href="#date">Date</a> object using local time. |
|
|
321
|
+
| **setUTCSeconds** | (sec: number, ms?: number \| undefined) => number | Sets the seconds value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
322
|
+
| **setMinutes** | (min: number, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the minutes value in the <a href="#date">Date</a> object using local time. |
|
|
323
|
+
| **setUTCMinutes** | (min: number, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the minutes value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
324
|
+
| **setHours** | (hours: number, min?: number \| undefined, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the hour value in the <a href="#date">Date</a> object using local time. |
|
|
325
|
+
| **setUTCHours** | (hours: number, min?: number \| undefined, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the hours value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
326
|
+
| **setDate** | (date: number) => number | Sets the numeric day-of-the-month value of the <a href="#date">Date</a> object using local time. |
|
|
327
|
+
| **setUTCDate** | (date: number) => number | Sets the numeric day of the month in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
328
|
+
| **setMonth** | (month: number, date?: number \| undefined) => number | Sets the month value in the <a href="#date">Date</a> object using local time. |
|
|
329
|
+
| **setUTCMonth** | (month: number, date?: number \| undefined) => number | Sets the month value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
330
|
+
| **setFullYear** | (year: number, month?: number \| undefined, date?: number \| undefined) => number | Sets the year of the <a href="#date">Date</a> object using local time. |
|
|
331
|
+
| **setUTCFullYear** | (year: number, month?: number \| undefined, date?: number \| undefined) => number | Sets the year value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
332
|
+
| **toUTCString** | () => string | Returns a date converted to a string using Universal Coordinated Time (UTC). |
|
|
333
|
+
| **toISOString** | () => string | Returns a date as a string value in ISO format. |
|
|
334
|
+
| **toJSON** | (key?: any) => string | Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. |
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
#### RemindersList
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
#### ReminderRecurrenceRule
|
|
341
|
+
|
|
342
|
+
| Prop | Type | Description |
|
|
343
|
+
| --------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
344
|
+
| **`frequency`** | <code><a href="#reminderrecurrencefrequency">ReminderRecurrenceFrequency</a></code> | How frequent should the reminder repeat. |
|
|
345
|
+
| **`interval`** | <code>number</code> | The interval should be a number greater than 0. For values lower than 1 the method will throw an error. |
|
|
346
|
+
| **`end`** | <code>number</code> | When provided, the reminder will stop repeating at the given time. |
|
|
347
|
+
|
|
348
|
+
|
|
229
349
|
### Type Aliases
|
|
230
350
|
|
|
231
351
|
|
|
@@ -237,6 +357,16 @@ Represents a calendar object with an ID and title.
|
|
|
237
357
|
### Enums
|
|
238
358
|
|
|
239
359
|
|
|
360
|
+
#### PluginPermission
|
|
361
|
+
|
|
362
|
+
| Members | Value | Description |
|
|
363
|
+
| --------------------- | ----------------------------- | ------------------------------------------------------ |
|
|
364
|
+
| **`READ_CALENDAR`** | <code>'readCalendar'</code> | Represents the permission state for reading calendar. |
|
|
365
|
+
| **`WRITE_CALENDAR`** | <code>'writeCalendar'</code> | Represents the permission state for writing calendar. |
|
|
366
|
+
| **`READ_REMINDERS`** | <code>'readReminders'</code> | Represents the permission state for reading reminders. |
|
|
367
|
+
| **`WRITE_REMINDERS`** | <code>'writeReminders'</code> | Represents the permission state for writing reminders. |
|
|
368
|
+
|
|
369
|
+
|
|
240
370
|
#### CalendarChooserDisplayStyle
|
|
241
371
|
|
|
242
372
|
| Members | Description |
|
|
@@ -252,4 +382,14 @@ Represents a calendar object with an ID and title.
|
|
|
252
382
|
| **`SINGLE`** | Allows only a single selection in the calendar chooser. |
|
|
253
383
|
| **`MULTIPLE`** | Allows multiple selections in the calendar chooser. |
|
|
254
384
|
|
|
385
|
+
|
|
386
|
+
#### ReminderRecurrenceFrequency
|
|
387
|
+
|
|
388
|
+
| Members |
|
|
389
|
+
| ------------- |
|
|
390
|
+
| **`DAILY`** |
|
|
391
|
+
| **`WEEKLY`** |
|
|
392
|
+
| **`MONTHLY`** |
|
|
393
|
+
| **`YEARLY`** |
|
|
394
|
+
|
|
255
395
|
</docgen-api>
|
package/android/build.gradle
CHANGED
|
@@ -26,7 +26,7 @@ android {
|
|
|
26
26
|
namespace "dev.barooni.capacitor.calendar"
|
|
27
27
|
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
28
28
|
defaultConfig {
|
|
29
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
29
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
|
|
30
30
|
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
31
31
|
versionCode 1
|
|
32
32
|
versionName "1.0"
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
package dev.barooni.capacitor.calendar
|
|
2
2
|
|
|
3
3
|
import android.content.ContentResolver
|
|
4
|
+
import android.content.ContentValues
|
|
4
5
|
import android.content.Context
|
|
6
|
+
import android.net.Uri
|
|
5
7
|
import android.provider.CalendarContract
|
|
6
8
|
import com.getcapacitor.JSArray
|
|
7
9
|
import com.getcapacitor.JSObject
|
|
10
|
+
import java.text.SimpleDateFormat
|
|
11
|
+
import java.util.Calendar
|
|
12
|
+
import java.util.Locale
|
|
13
|
+
import java.util.TimeZone
|
|
8
14
|
|
|
9
15
|
class CapacitorCalendar() {
|
|
10
16
|
var eventsCount: Int = 0
|
|
@@ -88,4 +94,33 @@ class CapacitorCalendar() {
|
|
|
88
94
|
}
|
|
89
95
|
throw Exception("No primary calendar found")
|
|
90
96
|
}
|
|
97
|
+
|
|
98
|
+
@Throws(Exception::class)
|
|
99
|
+
fun createEvent(
|
|
100
|
+
context: Context,
|
|
101
|
+
title: String,
|
|
102
|
+
calendarId: String?,
|
|
103
|
+
location: String?,
|
|
104
|
+
startDate: String?,
|
|
105
|
+
endDate: String?,
|
|
106
|
+
isAllDay: Boolean?
|
|
107
|
+
): Uri? {
|
|
108
|
+
val isoFormatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.getDefault()).apply {
|
|
109
|
+
timeZone = TimeZone.getTimeZone("UTC")
|
|
110
|
+
}
|
|
111
|
+
val startMillis = startDate?.let { isoFormatter.parse(it)?.time } ?: Calendar.getInstance().timeInMillis
|
|
112
|
+
val endMillis = endDate?.let { isoFormatter.parse(it)?.time } ?: (startMillis + 3600 * 1000)
|
|
113
|
+
|
|
114
|
+
val values = ContentValues().apply {
|
|
115
|
+
put(CalendarContract.Events.DTSTART, startMillis)
|
|
116
|
+
put(CalendarContract.Events.DTEND, endMillis)
|
|
117
|
+
put(CalendarContract.Events.TITLE, title)
|
|
118
|
+
location?.let { put(CalendarContract.Events.EVENT_LOCATION, it) }
|
|
119
|
+
put(CalendarContract.Events.CALENDAR_ID, calendarId ?: getDefaultCalendar(context).getString("id"))
|
|
120
|
+
put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone.getDefault().id)
|
|
121
|
+
isAllDay?.let { put(CalendarContract.Events.ALL_DAY, if (it) 1 else 0) }
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return context.contentResolver.insert(CalendarContract.Events.CONTENT_URI, values)
|
|
125
|
+
}
|
|
91
126
|
}
|
|
@@ -3,6 +3,7 @@ package dev.barooni.capacitor.calendar
|
|
|
3
3
|
import android.Manifest
|
|
4
4
|
import android.content.Intent
|
|
5
5
|
import android.provider.CalendarContract
|
|
6
|
+
import android.util.Log
|
|
6
7
|
import androidx.activity.result.ActivityResult
|
|
7
8
|
import com.getcapacitor.JSObject
|
|
8
9
|
import com.getcapacitor.Plugin
|
|
@@ -161,4 +162,43 @@ class CapacitorCalendarPlugin: Plugin() {
|
|
|
161
162
|
call.reject("", "[CapacitorCalendar.${::getDefaultCalendar.name}] No default calendar found")
|
|
162
163
|
}
|
|
163
164
|
}
|
|
165
|
+
|
|
166
|
+
@PluginMethod
|
|
167
|
+
fun createEvent(call: PluginCall) {
|
|
168
|
+
try {
|
|
169
|
+
val title = call.getString("title")
|
|
170
|
+
?: throw Exception("[CapacitorCalendar.${::createEvent.name}] A title for the event was not provided")
|
|
171
|
+
val calendarId = call.getString("calendarId")
|
|
172
|
+
val location = call.getString("location")
|
|
173
|
+
val startDate = call.getString("startDate")
|
|
174
|
+
val endDate = call.getString("endDate")
|
|
175
|
+
val isAllDay = call.getBoolean("isAllDay", false)
|
|
176
|
+
|
|
177
|
+
val eventUri = implementation.createEvent(context, title, calendarId, location, startDate, endDate, isAllDay)
|
|
178
|
+
val ret = JSObject()
|
|
179
|
+
ret.put("eventCreated", eventUri != null)
|
|
180
|
+
call.resolve(ret)
|
|
181
|
+
} catch (error: Exception) {
|
|
182
|
+
call.reject("", "[CapacitorCalendar.${::createEvent.name}] Unable to create event")
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@PluginMethod
|
|
188
|
+
fun getDefaultRemindersList(call: PluginCall) {
|
|
189
|
+
call.unimplemented("[CapacitorCalendar.${::getDefaultRemindersList.name}] Not implemented on Android")
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@PluginMethod
|
|
194
|
+
fun getRemindersLists(call: PluginCall) {
|
|
195
|
+
call.unimplemented("[CapacitorCalendar.${::getRemindersLists.name}] Not implemented on Android")
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@PluginMethod
|
|
200
|
+
fun createReminder(call: PluginCall) {
|
|
201
|
+
call.unimplemented("[CapacitorCalendar.${::createReminder.name}] Not implemented on Android")
|
|
202
|
+
return
|
|
203
|
+
}
|
|
164
204
|
}
|