@ebarooni/capacitor-calendar 0.9.0 → 0.10.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 +16 -6
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendar.kt +18 -9
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +13 -13
- package/dist/docs.json +21 -9
- package/dist/esm/definitions.d.ts +21 -17
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +2 -2
- package/dist/esm/web.js.map +1 -1
- package/ios/Plugin/CapacitorCalendar.swift +12 -6
- package/ios/Plugin/CapacitorCalendarPlugin.swift +3 -3
- package/ios/Plugin/CapacitorCalendarPluginError.swift +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
- [Demo](#demo--click-for-details-)
|
|
18
18
|
- [MVP](#mvp)
|
|
19
19
|
- [Permissions](#permissions)
|
|
20
|
+
- [Contributions](#contributions)
|
|
20
21
|
- [API](#api)
|
|
21
22
|
|
|
22
23
|
## Install
|
|
@@ -64,6 +65,17 @@ permissions can be found below:
|
|
|
64
65
|
- [iOS](./ios/PERMISSIONS.md)
|
|
65
66
|
- [Android](./android/PERMISSIONS.md)
|
|
66
67
|
|
|
68
|
+
## Contributions
|
|
69
|
+
|
|
70
|
+
Thank you for your interest in contributing to the project! At the moment, the focus is on reaching the first major
|
|
71
|
+
release. Until then, the contributions will not be accepted. This approach allows to set a solid
|
|
72
|
+
foundation and maintain consistency throughout the development process.
|
|
73
|
+
|
|
74
|
+
Community input is highly valued, and you are encouraged to engage with the project by providing feedback and suggestions.
|
|
75
|
+
Feel free to open issues for bugs you've discovered or enhancements you'd like to see.
|
|
76
|
+
|
|
77
|
+
Stay tuned for updates. Looking forward to collaborating with you in the future once contributions are opened up in the future!
|
|
78
|
+
|
|
67
79
|
## API
|
|
68
80
|
|
|
69
81
|
<docgen-index>
|
|
@@ -156,15 +168,13 @@ Requests authorization to all the required permissions for the plugin, if they h
|
|
|
156
168
|
### createEventWithPrompt()
|
|
157
169
|
|
|
158
170
|
```typescript
|
|
159
|
-
createEventWithPrompt() => Promise<{
|
|
171
|
+
createEventWithPrompt() => Promise<{ result: string[]; }>
|
|
160
172
|
```
|
|
161
173
|
|
|
162
174
|
Creates an event in the calendar by using the native calendar.
|
|
163
175
|
On iOS opens a native sheet and on Android opens an intent.
|
|
164
|
-
This method does not need any read or write authorization from the user on iOS. However, the entries in the Info.plist file are still needed.
|
|
165
|
-
On Android, the user has to authorize for read access.
|
|
166
176
|
|
|
167
|
-
**Returns:** <code>Promise<{
|
|
177
|
+
**Returns:** <code>Promise<{ result: string[]; }></code>
|
|
168
178
|
|
|
169
179
|
--------------------
|
|
170
180
|
|
|
@@ -215,7 +225,7 @@ Retrieves the default calendar set on the device.
|
|
|
215
225
|
### createEvent(...)
|
|
216
226
|
|
|
217
227
|
```typescript
|
|
218
|
-
createEvent(options: { title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; }) => Promise<{
|
|
228
|
+
createEvent(options: { title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; }) => Promise<{ result: string[]; }>
|
|
219
229
|
```
|
|
220
230
|
|
|
221
231
|
Creates an event with the provided options.
|
|
@@ -224,7 +234,7 @@ Creates an event with the provided options.
|
|
|
224
234
|
| ------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
|
|
225
235
|
| **`options`** | <code>{ title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; }</code> | - Options for creating the event. |
|
|
226
236
|
|
|
227
|
-
**Returns:** <code>Promise<{
|
|
237
|
+
**Returns:** <code>Promise<{ result: string[]; }></code>
|
|
228
238
|
|
|
229
239
|
--------------------
|
|
230
240
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package dev.barooni.capacitor.calendar
|
|
2
2
|
|
|
3
|
-
import android.content.ContentResolver
|
|
4
3
|
import android.content.ContentValues
|
|
5
4
|
import android.content.Context
|
|
6
5
|
import android.content.Intent
|
|
@@ -12,17 +11,27 @@ import java.util.Calendar
|
|
|
12
11
|
import java.util.TimeZone
|
|
13
12
|
|
|
14
13
|
class CapacitorCalendar() {
|
|
15
|
-
var
|
|
14
|
+
var eventIdsArray: List<Long> = emptyList()
|
|
16
15
|
|
|
17
16
|
@Throws(Exception::class)
|
|
18
|
-
fun
|
|
19
|
-
val contentResolver: ContentResolver = context.contentResolver
|
|
20
|
-
val uri = CalendarContract.Events.CONTENT_URI
|
|
17
|
+
fun fetchCalendarEventIDs(context: Context): List<Long> {
|
|
21
18
|
val projection = arrayOf(CalendarContract.Events._ID)
|
|
22
|
-
val
|
|
23
|
-
val
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
val uri = CalendarContract.Events.CONTENT_URI
|
|
20
|
+
val cursor = context.contentResolver.query(uri, projection, null, null, null)
|
|
21
|
+
val eventIds = mutableListOf<Long>()
|
|
22
|
+
|
|
23
|
+
cursor?.use {
|
|
24
|
+
while (it.moveToNext()) {
|
|
25
|
+
val eventId = it.getLong(0)
|
|
26
|
+
eventIds.add(eventId)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return eventIds
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Throws(Exception::class)
|
|
33
|
+
fun getNewEventIds(newIds: List<Long>): List<Long> {
|
|
34
|
+
return newIds.filterNot { it in eventIdsArray }
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
@Throws(Exception::class)
|
|
@@ -4,6 +4,7 @@ import android.Manifest
|
|
|
4
4
|
import android.content.Intent
|
|
5
5
|
import android.provider.CalendarContract
|
|
6
6
|
import androidx.activity.result.ActivityResult
|
|
7
|
+
import com.getcapacitor.JSArray
|
|
7
8
|
import com.getcapacitor.JSObject
|
|
8
9
|
import com.getcapacitor.Plugin
|
|
9
10
|
import com.getcapacitor.PluginCall
|
|
@@ -36,7 +37,7 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
36
37
|
@PluginMethod(returnType = PluginMethod.RETURN_PROMISE)
|
|
37
38
|
fun createEventWithPrompt(call: PluginCall) {
|
|
38
39
|
try {
|
|
39
|
-
implementation.
|
|
40
|
+
implementation.eventIdsArray = implementation.fetchCalendarEventIDs(context)
|
|
40
41
|
return startActivityForResult(
|
|
41
42
|
call,
|
|
42
43
|
Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI),
|
|
@@ -56,18 +57,13 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
56
57
|
if (call == null) {
|
|
57
58
|
throw Exception("[CapacitorCalendar.${::createEventWithPrompt.name}] Call is not defined")
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
val
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
false
|
|
65
|
-
} else {
|
|
66
|
-
call.reject("", "[CapacitorCalendar.${::openCalendarIntentActivityCallback.name}] Could not create the event")
|
|
67
|
-
return
|
|
68
|
-
}
|
|
60
|
+
|
|
61
|
+
val newEventIds = implementation.getNewEventIds(implementation.fetchCalendarEventIDs(context))
|
|
62
|
+
val newIdsArray = JSArray()
|
|
63
|
+
newEventIds.forEach { id -> newIdsArray.put(id.toString()) }
|
|
64
|
+
|
|
69
65
|
val ret = JSObject()
|
|
70
|
-
ret.put("
|
|
66
|
+
ret.put("result", newIdsArray)
|
|
71
67
|
call.resolve(ret)
|
|
72
68
|
}
|
|
73
69
|
|
|
@@ -183,8 +179,12 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
183
179
|
val isAllDay = call.getBoolean("isAllDay", false)
|
|
184
180
|
|
|
185
181
|
val eventUri = implementation.createEvent(context, title, calendarId, location, startDate, endDate, isAllDay)
|
|
182
|
+
val id = eventUri?.lastPathSegment ?: throw IllegalArgumentException("Failed to insert event into calendar")
|
|
186
183
|
val ret = JSObject()
|
|
187
|
-
|
|
184
|
+
val array = JSArray()
|
|
185
|
+
array.put(id)
|
|
186
|
+
|
|
187
|
+
ret.put("result", array)
|
|
188
188
|
call.resolve(ret)
|
|
189
189
|
} catch (error: Exception) {
|
|
190
190
|
call.reject("", "[CapacitorCalendar.${::createEvent.name}] Unable to create event")
|
package/dist/docs.json
CHANGED
|
@@ -141,9 +141,9 @@
|
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
"name": "createEventWithPrompt",
|
|
144
|
-
"signature": "() => Promise<{
|
|
144
|
+
"signature": "() => Promise<{ result: string[]; }>",
|
|
145
145
|
"parameters": [],
|
|
146
|
-
"returns": "Promise<{
|
|
146
|
+
"returns": "Promise<{ result: string[]; }>",
|
|
147
147
|
"tags": [
|
|
148
148
|
{
|
|
149
149
|
"name": "method"
|
|
@@ -152,16 +152,24 @@
|
|
|
152
152
|
"name": "platform",
|
|
153
153
|
"text": "iOS, Android"
|
|
154
154
|
},
|
|
155
|
+
{
|
|
156
|
+
"name": "permissions",
|
|
157
|
+
"text": "<h3>Runtime Permissions:</h3>\n<ul>\n <li><strong>Android:</strong> readCalendar</li>\n</ul>"
|
|
158
|
+
},
|
|
155
159
|
{
|
|
156
160
|
"name": "returns",
|
|
157
|
-
"text": "
|
|
161
|
+
"text": "A promise that resolves with an array of the ids of created events."
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "throws",
|
|
165
|
+
"text": "Error If prompt gets cancelled."
|
|
158
166
|
},
|
|
159
167
|
{
|
|
160
168
|
"name": "example",
|
|
161
|
-
"text": "
|
|
169
|
+
"text": "if (capacitor.getPlatform() === 'android') {\n await this.requestPermission({ alias: 'readCalendar' });\n { result } = result = await this.createEventWithPrompt();\n} else {\n { result } = await this.createEventWithPrompt();\n}"
|
|
162
170
|
}
|
|
163
171
|
],
|
|
164
|
-
"docs": "Creates an event in the calendar by using the native calendar.\nOn iOS opens a native sheet and on Android opens an intent
|
|
172
|
+
"docs": "Creates an event in the calendar by using the native calendar.\nOn iOS opens a native sheet and on Android opens an intent.",
|
|
165
173
|
"complexTypes": [],
|
|
166
174
|
"slug": "createeventwithprompt"
|
|
167
175
|
},
|
|
@@ -272,7 +280,7 @@
|
|
|
272
280
|
},
|
|
273
281
|
{
|
|
274
282
|
"name": "createEvent",
|
|
275
|
-
"signature": "(options: { title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; }) => Promise<{
|
|
283
|
+
"signature": "(options: { title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; }) => Promise<{ result: string[]; }>",
|
|
276
284
|
"parameters": [
|
|
277
285
|
{
|
|
278
286
|
"name": "options",
|
|
@@ -280,7 +288,7 @@
|
|
|
280
288
|
"type": "{ title: string; calendarId?: string | undefined; location?: string | undefined; startDate?: number | undefined; endDate?: number | undefined; isAllDay?: boolean | undefined; }"
|
|
281
289
|
}
|
|
282
290
|
],
|
|
283
|
-
"returns": "Promise<{
|
|
291
|
+
"returns": "Promise<{ result: string[]; }>",
|
|
284
292
|
"tags": [
|
|
285
293
|
{
|
|
286
294
|
"name": "method",
|
|
@@ -290,17 +298,21 @@
|
|
|
290
298
|
"name": "platform",
|
|
291
299
|
"text": "iOS, Android"
|
|
292
300
|
},
|
|
301
|
+
{
|
|
302
|
+
"name": "permissions",
|
|
303
|
+
"text": "<h3>Runtime Permissions:</h3>\n<ul>\n <li><strong>iOS 17 ≤:</strong> writeCalendar</li>\n <li><strong>iOS 10 ≤ x ≤ iOS 16:</strong> writeCalendar</li>\n <li><strong>Android:</strong> readCalendar, writeCalendar</li>\n</ul>"
|
|
304
|
+
},
|
|
293
305
|
{
|
|
294
306
|
"name": "param",
|
|
295
307
|
"text": "options - Options for creating the event."
|
|
296
308
|
},
|
|
297
309
|
{
|
|
298
310
|
"name": "returns",
|
|
299
|
-
"text": "A
|
|
311
|
+
"text": "A promise that resolves with an array of the ids of created events."
|
|
300
312
|
},
|
|
301
313
|
{
|
|
302
314
|
"name": "example",
|
|
303
|
-
"text": "const now = Date.now();\nconst eventOptions = {\n title: 'Team Meeting',\n location: 'Conference Room A',\n startDate: now,\n endDate: now + 2 * 60 * 60 * 1000,\n isAllDay: false\n};\nconst {
|
|
315
|
+
"text": "const now = Date.now();\nconst eventOptions = {\n title: 'Team Meeting',\n location: 'Conference Room A',\n startDate: now,\n endDate: now + 2 * 60 * 60 * 1000,\n isAllDay: false\n};\nconst { result } = await createEvent(eventOptions);"
|
|
304
316
|
}
|
|
305
317
|
],
|
|
306
318
|
"docs": "Creates an event with the provided options.",
|
|
@@ -62,27 +62,26 @@ export interface CapacitorCalendarPlugin {
|
|
|
62
62
|
/**
|
|
63
63
|
* Creates an event in the calendar by using the native calendar.
|
|
64
64
|
* On iOS opens a native sheet and on Android opens an intent.
|
|
65
|
-
* This method does not need any read or write authorization from the user on iOS. However, the entries in the Info.plist file are still needed.
|
|
66
|
-
* On Android, the user has to authorize for read access.
|
|
67
65
|
*
|
|
68
66
|
* @method
|
|
69
67
|
* @platform iOS, Android
|
|
70
|
-
* @
|
|
68
|
+
* @permissions
|
|
69
|
+
* <h3>Runtime Permissions:</h3>
|
|
70
|
+
* <ul>
|
|
71
|
+
* <li><strong>Android:</strong> readCalendar</li>
|
|
72
|
+
* </ul>
|
|
73
|
+
* @returns {Promise<{ result: string[] }>} A promise that resolves with an array of the ids of created events.
|
|
74
|
+
* @throws Error If prompt gets cancelled.
|
|
71
75
|
* @example
|
|
72
|
-
* let result: CalendarEventActionResult;
|
|
73
76
|
* if (capacitor.getPlatform() === 'android') {
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* result = await this.createEventWithPrompt();
|
|
77
|
-
* } else {
|
|
78
|
-
* // handle the case when user rejects the permission
|
|
79
|
-
* }
|
|
77
|
+
* await this.requestPermission({ alias: 'readCalendar' });
|
|
78
|
+
* { result } = result = await this.createEventWithPrompt();
|
|
80
79
|
* } else {
|
|
81
|
-
* result = await this.createEventWithPrompt();
|
|
80
|
+
* { result } = await this.createEventWithPrompt();
|
|
82
81
|
* }
|
|
83
82
|
*/
|
|
84
83
|
createEventWithPrompt(): Promise<{
|
|
85
|
-
|
|
84
|
+
result: string[];
|
|
86
85
|
}>;
|
|
87
86
|
/**
|
|
88
87
|
* Presents a prompt to the user to select calendars. This method is available only on iOS.
|
|
@@ -139,6 +138,13 @@ export interface CapacitorCalendarPlugin {
|
|
|
139
138
|
*
|
|
140
139
|
* @method createEvent
|
|
141
140
|
* @platform iOS, Android
|
|
141
|
+
* @permissions
|
|
142
|
+
* <h3>Runtime Permissions:</h3>
|
|
143
|
+
* <ul>
|
|
144
|
+
* <li><strong>iOS 17 ≤:</strong> writeCalendar</li>
|
|
145
|
+
* <li><strong>iOS 10 ≤ x ≤ iOS 16:</strong> writeCalendar</li>
|
|
146
|
+
* <li><strong>Android:</strong> readCalendar, writeCalendar</li>
|
|
147
|
+
* </ul>
|
|
142
148
|
* @param {object} options - Options for creating the event.
|
|
143
149
|
* @param {string} options.title - The title of the event.
|
|
144
150
|
* @param {string} options.calendarId - The id of the destination calendar. (Optional)
|
|
@@ -146,8 +152,7 @@ export interface CapacitorCalendarPlugin {
|
|
|
146
152
|
* @param {number} [options.startDate] - The start date and time of the event. (Optional)
|
|
147
153
|
* @param {number} [options.endDate] - The end date and time of the event. (Optional)
|
|
148
154
|
* @param {boolean} [options.isAllDay] - Weather the event is for the entire day or not. (Optional)
|
|
149
|
-
* @returns {Promise<{
|
|
150
|
-
* The resolved object has a property 'eventCreated' which is a boolean value representing whether the event was created.
|
|
155
|
+
* @returns {Promise<{ result: string[] }>} A promise that resolves with an array of the ids of created events.
|
|
151
156
|
* @example
|
|
152
157
|
* const now = Date.now();
|
|
153
158
|
* const eventOptions = {
|
|
@@ -157,8 +162,7 @@ export interface CapacitorCalendarPlugin {
|
|
|
157
162
|
* endDate: now + 2 * 60 * 60 * 1000,
|
|
158
163
|
* isAllDay: false
|
|
159
164
|
* };
|
|
160
|
-
* const {
|
|
161
|
-
* console.log(eventCreated); // true
|
|
165
|
+
* const { result } = await createEvent(eventOptions);
|
|
162
166
|
*/
|
|
163
167
|
createEvent(options: {
|
|
164
168
|
title: string;
|
|
@@ -168,7 +172,7 @@ export interface CapacitorCalendarPlugin {
|
|
|
168
172
|
endDate?: number;
|
|
169
173
|
isAllDay?: boolean;
|
|
170
174
|
}): Promise<{
|
|
171
|
-
|
|
175
|
+
result: string[];
|
|
172
176
|
}>;
|
|
173
177
|
/**
|
|
174
178
|
* Retrieves the default reminders list set on the device.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import { CalendarChooserDisplayStyle } from './schemas/enums/calendar-chooser-display-style';\nimport { CalendarChooserSelectionStyle } from './schemas/enums/calendar-chooser-selection-style';\nimport { PluginPermission } from './schemas/enums/plugin-permission';\nimport type { PermissionState } from '@capacitor/core';\nimport type { Calendar } from './schemas/interfaces/calendar';\nimport type { RemindersList } from './schemas/interfaces/reminders-list';\nimport type { PluginPermissionsMap } from './schemas/interfaces/plugin-permissions-map';\nimport type { ReminderRecurrenceRule } from './schemas/interfaces/reminder-recurrence-rule';\nimport type { CalendarEvent } from './schemas/interfaces/calendar-event';\n\nexport interface CapacitorCalendarPlugin {\n /**\n * Checks the current authorization status of a specific permission.\n *\n * @method\n * @platform iOS, Android\n * @param options An object with the name of the permission\n * @returns {Promise<{ result: PermissionState }>} – A promise that resolves with the current status of the requested permission.\n * @example\n * const status = await this.checkPermission({ alias: 'readCalendar' });\n */\n checkPermission(options: { alias: PluginPermission }): Promise<{ result: PermissionState }>;\n\n /**\n * Checks the current authorization status of all the required permissions for the plugin.\n *\n * @method\n * @platform iOS, Android\n * @returns {Promise<PluginPermissionsMap>} – A promise that resolves with an object containing all the permissions and their status.\n * @example\n * const permissionsStatus = await this.checkAllPermissions();\n */\n checkAllPermissions(): Promise<PluginPermissionsMap>;\n\n /**\n * Requests authorization to a specific permission, if not already granted.\n * If the permission is already granted, it will directly return the status.\n *\n * @method\n * @platform iOS, Android\n * @param options An object with the name of the permission\n * @returns {Promise<{ result: PermissionState }>} – A promise that resolves with the new permission status after the request is made.\n * @example\n * const result = await this.requestPermission({ alias: 'readCalendar' });\n */\n requestPermission(options: { alias: PluginPermission }): Promise<{ result: PermissionState }>;\n\n /**\n * Requests authorization to all the required permissions for the plugin, if they have not already been granted.\n *\n * @method\n * @platform iOS, Android\n * @returns {Promise<PluginPermissionsMap>} – A promise that resolves with the new permission statuses after the request is made.\n * @example\n * const permissionResults = await this.requestAllPermissions();\n */\n requestAllPermissions(): Promise<PluginPermissionsMap>;\n\n /**\n * Creates an event in the calendar by using the native calendar.\n * On iOS opens a native sheet and on Android opens an intent.\n * This method does not need any read or write authorization from the user on iOS. However, the entries in the Info.plist file are still needed.\n * On Android, the user has to authorize for read access.\n *\n * @method\n * @platform iOS, Android\n * @returns {Promise<{ eventCreated: boolean }>} – A promise that resolves with the result of the action.\n * @example\n * let result: CalendarEventActionResult;\n * if (capacitor.getPlatform() === 'android') {\n * const readCalendarStatus = (await this.requestPermission({ alias: 'readCalendar' })).result;\n * if (readCalendarStatus === 'granted') {\n * result = await this.createEventWithPrompt();\n * } else {\n * // handle the case when user rejects the permission\n * }\n * } else {\n * result = await this.createEventWithPrompt();\n * }\n */\n createEventWithPrompt(): Promise<{ eventCreated: boolean }>;\n\n /**\n * Presents a prompt to the user to select calendars. This method is available only on iOS.\n *\n * @method selectCalendarsWithPrompt\n * @platform iOS\n * @param {object} options - Options for customizing the display and selection styles of the calendar chooser.\n * @async\n * @returns { Promise<{ result: Calendar[] }> } A promise that resolves with an array of selected calendars,\n * where each calendar object contains an ID and a title.\n * @example\n * if (capacitor.getPlatform() === 'ios') {\n * const { result } = await selectCalendarsWithPrompt();\n * console.log(result); // [{ id: '1', title: 'Work Calendar' }]\n * }\n */\n selectCalendarsWithPrompt(options: {\n displayStyle: CalendarChooserDisplayStyle;\n selectionStyle: CalendarChooserSelectionStyle;\n }): Promise<{ result: Calendar[] }>;\n\n /**\n * Retrieves a list of calendars available on the device.\n *\n * @async\n * @method listCalendars\n * @platform iOS, Android\n * @returns {Promise<{ result: Calendar[] }>} A promise that resolves with an array of calendars available on the device.\n * Each calendar object in the array contains an ID and a title.\n * @example\n * const { result } = await listCalendars();\n * console.log(result); // [{ id: '1', title: 'Work Calendar' }, { id: '2', title: 'Personal Calendar' }]\n */\n listCalendars(): Promise<{ result: Calendar[] }>;\n\n /**\n * Retrieves the default calendar set on the device.\n *\n * @method getDefaultCalendar\n * @platform iOS, Android\n * @returns {Promise<{ result: Calendar }>} A promise that resolves with the default calendar set on the device.\n * The returned calendar object contains an ID and a title.\n * @example\n * const { result } = await getDefaultCalendar();\n * console.log(result); // { id: '1', title: 'Default Calendar' }\n */\n getDefaultCalendar(): Promise<{ result: Calendar }>;\n\n /**\n * Creates an event with the provided options.\n *\n * @method createEvent\n * @platform iOS, Android\n * @param {object} options - Options for creating the event.\n * @param {string} options.title - The title of the event.\n * @param {string} options.calendarId - The id of the destination calendar. (Optional)\n * @param {string} [options.location] - The location of the event. (Optional)\n * @param {number} [options.startDate] - The start date and time of the event. (Optional)\n * @param {number} [options.endDate] - The end date and time of the event. (Optional)\n * @param {boolean} [options.isAllDay] - Weather the event is for the entire day or not. (Optional)\n * @returns {Promise<{ eventCreated: boolean }>} A Promise that resolves with an object indicating whether the event was created successfully.\n * The resolved object has a property 'eventCreated' which is a boolean value representing whether the event was created.\n * @example\n * const now = Date.now();\n * const eventOptions = {\n * title: 'Team Meeting',\n * location: 'Conference Room A',\n * startDate: now,\n * endDate: now + 2 * 60 * 60 * 1000,\n * isAllDay: false\n * };\n * const { eventCreated } = await createEvent(eventOptions);\n * console.log(eventCreated); // true\n */\n createEvent(options: {\n title: string;\n calendarId?: string;\n location?: string;\n startDate?: number;\n endDate?: number;\n isAllDay?: boolean;\n }): Promise<{ eventCreated: boolean }>;\n\n /**\n * Retrieves the default reminders list set on the device.\n *\n * @method getDefaultRemindersList\n * @platform iOS\n * @returns {Promise<{ result: RemindersList }>} A promise that resolves with the default reminder list set on the device.\n * The returned reminders list object contains an ID and a title.\n * @example\n * const { result } = await getDefaultRemindersList();\n * console.log(result); // { id: '1', title: 'Default Reminders List' }\n */\n getDefaultRemindersList(): Promise<{ result: RemindersList }>;\n\n /**\n * Retrieves all available reminders lists on the device.\n *\n * @async\n * @method getRemindersLists\n * @platform iOS\n * @returns {Promise<{ result: RemindersList[] }>} A promise that resolves with an array of reminders lists available on the device.\n * Each reminders list object in the array contains an ID and a title.\n * @example\n * const { result } = await getRemindersLists();\n * console.log(result); // [{ id: '1', title: 'Groceries' }, { id: '2', title: 'Subscriptions' }]\n */\n getRemindersLists(): Promise<{ result: RemindersList[] }>;\n\n /**\n * Creates a reminder with the provided options.\n *\n * @method createReminder\n * @platform iOS\n * @param {object} options - Options for creating the reminder.\n * @param {string} options.title - The title of the reminder.\n * @param {string} options.listId - The id of the destination reminders list. (Optional)\n * @param {number} [options.priority] - The priority of the reminder. A number between one and nine where nine\n * has the least priority and 0 means no priority at all. Values outside of this range will be rounded to the\n * nearest border. (Optional)\n * @param {boolean} [options.isCompleted] - Whether the reminder is completed already or not. (Optional)\n * @param {number} [options.startDate] - The start date of the reminder. (Optional)\n * @param {number} [options.dueDate] - The due date of the reminder. (Optional)\n * @param {number} [options.completionDate] - The date at which the reminder was completed. (Optional)\n * @param {string} [options.notes] - Additional notes about the reminder. (Optional)\n * @param {string} [options.url] - A URL to save under the reminder. (Optional)\n * @param {string} [options.location] - A location to save under the reminder. (Optional)\n * @param {string} [options.recurrence] - The rules for the recurrence of the reminder. (Optional)\n * @returns {Promise<{ reminderCreated: boolean }>} A Promise that resolves with an object indicating whether the reminder was created successfully.\n * The resolved object has a property 'reminderCreated' which is a boolean value representing whether the reminder was created.\n * @example\n * const now = Date.now();\n * const rules: ReminderRecurrenceRule = {\n * frequency: ReminderRecurrenceFrequency.MONTHLY,\n * interval: 10,\n * end: Date.now()\n * }\n * const reminderOptions = {\n * title: 'Buy cucumber',\n * listId: 'ABC12',\n * priority: 5,\n * isCompleted: false,\n * startDateComponents: now,\n * notes: 'Also buy tomatoes',\n * url: 'https://capacitor-calendar.pages.dev/',\n * location: 'My Local Supermarket',\n * recurrence: rules\n * };\n * const { reminderCreated } = await createReminder(reminderOptions);\n * console.log(reminderCreated); // true\n */\n createReminder(options: {\n title: string;\n listId?: string;\n priority?: number;\n isCompleted?: boolean;\n startDate?: number;\n dueDate?: number;\n completionDate?: number;\n notes?: string;\n url?: string;\n location?: string;\n recurrence?: ReminderRecurrenceRule;\n }): Promise<{ reminderCreated: boolean }>;\n\n /**\n * Opens the calendar app. Since the user leaves your app, use this method with caution.\n * It will open the calendar on today's date if no date is provided.\n *\n * @method openCalendar\n * @platform iOS, Android\n * @param {object} options - Options for opening the calendar.\n * @param {number} options.date - The date at which the calendar should be opened. (Optional)\n * @returns {Promise<void>}\n * @example\n * void CapacitorCalendar.openCalendar({ date: Date.now() });\n */\n openCalendar(options: { date?: number }): Promise<void>;\n\n /**\n * Opens the reminders app. Since the user leaves your app, use this method with caution.\n *\n * @method openReminders\n * @platform iOS\n * @returns {Promise<void>}\n * @example\n * void CapacitorCalendar.openReminders();\n */\n openReminders(): Promise<void>;\n\n /**\n * Retrieves the list of calendar events present in the given date range.\n *\n * @method listEventsInRange\n * @platform iOS, Android\n * @param {object} options Options for defining the date range.\n * @param {number} options.startDate The start of the date range.\n * @param {number} options.endDate The end of the date range.\n * @returns {Promise<{ result: CalendarEvent[] }>} A Promise that resolves with the list of events.\n * @example\n * const { result } = await CapacitorCalendar.listEventsInRange({\n * startDate: Date.now(),\n * endDate: Date.now() + 6 * 7 * 24 * 60 * 60 * 1000, // 6 weeks from now\n * })\n */\n listEventsInRange(options: { startDate: number; endDate: number }): Promise<{ result: CalendarEvent[] }>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import { CalendarChooserDisplayStyle } from './schemas/enums/calendar-chooser-display-style';\nimport { CalendarChooserSelectionStyle } from './schemas/enums/calendar-chooser-selection-style';\nimport { PluginPermission } from './schemas/enums/plugin-permission';\nimport type { PermissionState } from '@capacitor/core';\nimport type { Calendar } from './schemas/interfaces/calendar';\nimport type { RemindersList } from './schemas/interfaces/reminders-list';\nimport type { PluginPermissionsMap } from './schemas/interfaces/plugin-permissions-map';\nimport type { ReminderRecurrenceRule } from './schemas/interfaces/reminder-recurrence-rule';\nimport type { CalendarEvent } from './schemas/interfaces/calendar-event';\n\nexport interface CapacitorCalendarPlugin {\n /**\n * Checks the current authorization status of a specific permission.\n *\n * @method\n * @platform iOS, Android\n * @param options An object with the name of the permission\n * @returns {Promise<{ result: PermissionState }>} – A promise that resolves with the current status of the requested permission.\n * @example\n * const status = await this.checkPermission({ alias: 'readCalendar' });\n */\n checkPermission(options: { alias: PluginPermission }): Promise<{ result: PermissionState }>;\n\n /**\n * Checks the current authorization status of all the required permissions for the plugin.\n *\n * @method\n * @platform iOS, Android\n * @returns {Promise<PluginPermissionsMap>} – A promise that resolves with an object containing all the permissions and their status.\n * @example\n * const permissionsStatus = await this.checkAllPermissions();\n */\n checkAllPermissions(): Promise<PluginPermissionsMap>;\n\n /**\n * Requests authorization to a specific permission, if not already granted.\n * If the permission is already granted, it will directly return the status.\n *\n * @method\n * @platform iOS, Android\n * @param options An object with the name of the permission\n * @returns {Promise<{ result: PermissionState }>} – A promise that resolves with the new permission status after the request is made.\n * @example\n * const result = await this.requestPermission({ alias: 'readCalendar' });\n */\n requestPermission(options: { alias: PluginPermission }): Promise<{ result: PermissionState }>;\n\n /**\n * Requests authorization to all the required permissions for the plugin, if they have not already been granted.\n *\n * @method\n * @platform iOS, Android\n * @returns {Promise<PluginPermissionsMap>} – A promise that resolves with the new permission statuses after the request is made.\n * @example\n * const permissionResults = await this.requestAllPermissions();\n */\n requestAllPermissions(): Promise<PluginPermissionsMap>;\n\n /**\n * Creates an event in the calendar by using the native calendar.\n * On iOS opens a native sheet and on Android opens an intent.\n *\n * @method\n * @platform iOS, Android\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>Android:</strong> readCalendar</li>\n * </ul>\n * @returns {Promise<{ result: string[] }>} A promise that resolves with an array of the ids of created events.\n * @throws Error If prompt gets cancelled.\n * @example\n * if (capacitor.getPlatform() === 'android') {\n * await this.requestPermission({ alias: 'readCalendar' });\n * { result } = result = await this.createEventWithPrompt();\n * } else {\n * { result } = await this.createEventWithPrompt();\n * }\n */\n createEventWithPrompt(): Promise<{ result: string[] }>;\n\n /**\n * Presents a prompt to the user to select calendars. This method is available only on iOS.\n *\n * @method selectCalendarsWithPrompt\n * @platform iOS\n * @param {object} options - Options for customizing the display and selection styles of the calendar chooser.\n * @async\n * @returns { Promise<{ result: Calendar[] }> } A promise that resolves with an array of selected calendars,\n * where each calendar object contains an ID and a title.\n * @example\n * if (capacitor.getPlatform() === 'ios') {\n * const { result } = await selectCalendarsWithPrompt();\n * console.log(result); // [{ id: '1', title: 'Work Calendar' }]\n * }\n */\n selectCalendarsWithPrompt(options: {\n displayStyle: CalendarChooserDisplayStyle;\n selectionStyle: CalendarChooserSelectionStyle;\n }): Promise<{ result: Calendar[] }>;\n\n /**\n * Retrieves a list of calendars available on the device.\n *\n * @async\n * @method listCalendars\n * @platform iOS, Android\n * @returns {Promise<{ result: Calendar[] }>} A promise that resolves with an array of calendars available on the device.\n * Each calendar object in the array contains an ID and a title.\n * @example\n * const { result } = await listCalendars();\n * console.log(result); // [{ id: '1', title: 'Work Calendar' }, { id: '2', title: 'Personal Calendar' }]\n */\n listCalendars(): Promise<{ result: Calendar[] }>;\n\n /**\n * Retrieves the default calendar set on the device.\n *\n * @method getDefaultCalendar\n * @platform iOS, Android\n * @returns {Promise<{ result: Calendar }>} A promise that resolves with the default calendar set on the device.\n * The returned calendar object contains an ID and a title.\n * @example\n * const { result } = await getDefaultCalendar();\n * console.log(result); // { id: '1', title: 'Default Calendar' }\n */\n getDefaultCalendar(): Promise<{ result: Calendar }>;\n\n /**\n * Creates an event with the provided options.\n *\n * @method createEvent\n * @platform iOS, Android\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>iOS 17 ≤:</strong> writeCalendar</li>\n * <li><strong>iOS 10 ≤ x ≤ iOS 16:</strong> writeCalendar</li>\n * <li><strong>Android:</strong> readCalendar, writeCalendar</li>\n * </ul>\n * @param {object} options - Options for creating the event.\n * @param {string} options.title - The title of the event.\n * @param {string} options.calendarId - The id of the destination calendar. (Optional)\n * @param {string} [options.location] - The location of the event. (Optional)\n * @param {number} [options.startDate] - The start date and time of the event. (Optional)\n * @param {number} [options.endDate] - The end date and time of the event. (Optional)\n * @param {boolean} [options.isAllDay] - Weather the event is for the entire day or not. (Optional)\n * @returns {Promise<{ result: string[] }>} A promise that resolves with an array of the ids of created events.\n * @example\n * const now = Date.now();\n * const eventOptions = {\n * title: 'Team Meeting',\n * location: 'Conference Room A',\n * startDate: now,\n * endDate: now + 2 * 60 * 60 * 1000,\n * isAllDay: false\n * };\n * const { result } = await createEvent(eventOptions);\n */\n createEvent(options: {\n title: string;\n calendarId?: string;\n location?: string;\n startDate?: number;\n endDate?: number;\n isAllDay?: boolean;\n }): Promise<{ result: string[] }>;\n\n /**\n * Retrieves the default reminders list set on the device.\n *\n * @method getDefaultRemindersList\n * @platform iOS\n * @returns {Promise<{ result: RemindersList }>} A promise that resolves with the default reminder list set on the device.\n * The returned reminders list object contains an ID and a title.\n * @example\n * const { result } = await getDefaultRemindersList();\n * console.log(result); // { id: '1', title: 'Default Reminders List' }\n */\n getDefaultRemindersList(): Promise<{ result: RemindersList }>;\n\n /**\n * Retrieves all available reminders lists on the device.\n *\n * @async\n * @method getRemindersLists\n * @platform iOS\n * @returns {Promise<{ result: RemindersList[] }>} A promise that resolves with an array of reminders lists available on the device.\n * Each reminders list object in the array contains an ID and a title.\n * @example\n * const { result } = await getRemindersLists();\n * console.log(result); // [{ id: '1', title: 'Groceries' }, { id: '2', title: 'Subscriptions' }]\n */\n getRemindersLists(): Promise<{ result: RemindersList[] }>;\n\n /**\n * Creates a reminder with the provided options.\n *\n * @method createReminder\n * @platform iOS\n * @param {object} options - Options for creating the reminder.\n * @param {string} options.title - The title of the reminder.\n * @param {string} options.listId - The id of the destination reminders list. (Optional)\n * @param {number} [options.priority] - The priority of the reminder. A number between one and nine where nine\n * has the least priority and 0 means no priority at all. Values outside of this range will be rounded to the\n * nearest border. (Optional)\n * @param {boolean} [options.isCompleted] - Whether the reminder is completed already or not. (Optional)\n * @param {number} [options.startDate] - The start date of the reminder. (Optional)\n * @param {number} [options.dueDate] - The due date of the reminder. (Optional)\n * @param {number} [options.completionDate] - The date at which the reminder was completed. (Optional)\n * @param {string} [options.notes] - Additional notes about the reminder. (Optional)\n * @param {string} [options.url] - A URL to save under the reminder. (Optional)\n * @param {string} [options.location] - A location to save under the reminder. (Optional)\n * @param {string} [options.recurrence] - The rules for the recurrence of the reminder. (Optional)\n * @returns {Promise<{ reminderCreated: boolean }>} A Promise that resolves with an object indicating whether the reminder was created successfully.\n * The resolved object has a property 'reminderCreated' which is a boolean value representing whether the reminder was created.\n * @example\n * const now = Date.now();\n * const rules: ReminderRecurrenceRule = {\n * frequency: ReminderRecurrenceFrequency.MONTHLY,\n * interval: 10,\n * end: Date.now()\n * }\n * const reminderOptions = {\n * title: 'Buy cucumber',\n * listId: 'ABC12',\n * priority: 5,\n * isCompleted: false,\n * startDateComponents: now,\n * notes: 'Also buy tomatoes',\n * url: 'https://capacitor-calendar.pages.dev/',\n * location: 'My Local Supermarket',\n * recurrence: rules\n * };\n * const { reminderCreated } = await createReminder(reminderOptions);\n * console.log(reminderCreated); // true\n */\n createReminder(options: {\n title: string;\n listId?: string;\n priority?: number;\n isCompleted?: boolean;\n startDate?: number;\n dueDate?: number;\n completionDate?: number;\n notes?: string;\n url?: string;\n location?: string;\n recurrence?: ReminderRecurrenceRule;\n }): Promise<{ reminderCreated: boolean }>;\n\n /**\n * Opens the calendar app. Since the user leaves your app, use this method with caution.\n * It will open the calendar on today's date if no date is provided.\n *\n * @method openCalendar\n * @platform iOS, Android\n * @param {object} options - Options for opening the calendar.\n * @param {number} options.date - The date at which the calendar should be opened. (Optional)\n * @returns {Promise<void>}\n * @example\n * void CapacitorCalendar.openCalendar({ date: Date.now() });\n */\n openCalendar(options: { date?: number }): Promise<void>;\n\n /**\n * Opens the reminders app. Since the user leaves your app, use this method with caution.\n *\n * @method openReminders\n * @platform iOS\n * @returns {Promise<void>}\n * @example\n * void CapacitorCalendar.openReminders();\n */\n openReminders(): Promise<void>;\n\n /**\n * Retrieves the list of calendar events present in the given date range.\n *\n * @method listEventsInRange\n * @platform iOS, Android\n * @param {object} options Options for defining the date range.\n * @param {number} options.startDate The start of the date range.\n * @param {number} options.endDate The end of the date range.\n * @returns {Promise<{ result: CalendarEvent[] }>} A Promise that resolves with the list of events.\n * @example\n * const { result } = await CapacitorCalendar.listEventsInRange({\n * startDate: Date.now(),\n * endDate: Date.now() + 6 * 7 * 24 * 60 * 60 * 1000, // 6 weeks from now\n * })\n */\n listEventsInRange(options: { startDate: number; endDate: number }): Promise<{ result: CalendarEvent[] }>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare class CapacitorCalendarWeb extends WebPlugin implements Capacitor
|
|
|
20
20
|
}>;
|
|
21
21
|
requestAllPermissions(): Promise<PluginPermissionsMap>;
|
|
22
22
|
createEventWithPrompt(): Promise<{
|
|
23
|
-
|
|
23
|
+
result: string[];
|
|
24
24
|
}>;
|
|
25
25
|
selectCalendarsWithPrompt(): Promise<{
|
|
26
26
|
result: Calendar[];
|
|
@@ -39,7 +39,7 @@ export declare class CapacitorCalendarWeb extends WebPlugin implements Capacitor
|
|
|
39
39
|
endDate?: number;
|
|
40
40
|
isAllDay?: boolean;
|
|
41
41
|
}): Promise<{
|
|
42
|
-
|
|
42
|
+
result: string[];
|
|
43
43
|
}>;
|
|
44
44
|
createReminder(_options: {
|
|
45
45
|
title: string;
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAmB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS7D,MAAM,OAAO,oBAAqB,SAAQ,SAAS;IAC1C,eAAe,CAAC,QAAqC;QAC1D,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACzF,CAAC;IAEM,mBAAmB;QACxB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC7F,CAAC;IAEM,iBAAiB,CAAC,QAAqC;QAC5D,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC3F,CAAC;IAEM,qBAAqB;QAC1B,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC/F,CAAC;IAEM,qBAAqB;QAC1B,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC/F,CAAC;IAEM,yBAAyB;QAC9B,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC/F,CAAC;IAEM,aAAa;QAClB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACvF,CAAC;IAEM,kBAAkB;QACvB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC5F,CAAC;IAEM,WAAW,CAAC,QAOlB;QAGC,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACrF,CAAC;IAEM,cAAc,CAAC,QAYrB;QACC,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;IAEM,uBAAuB;QAC5B,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;IAEM,iBAAiB;QACtB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;IAEM,YAAY,CAAC,QAA2B;QAC7C,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;IAEM,aAAa;QAClB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;IAEM,iBAAiB,CAAC,QAAgD;QACvE,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { PermissionState, WebPlugin } from '@capacitor/core';\nimport { CapacitorCalendarPlugin } from './definitions';\nimport { PluginPermission } from './schemas/enums/plugin-permission';\nimport { ReminderRecurrenceRule } from './schemas/interfaces/reminder-recurrence-rule';\nimport type { Calendar } from './schemas/interfaces/calendar';\nimport type { RemindersList } from './schemas/interfaces/reminders-list';\nimport type { PluginPermissionsMap } from './schemas/interfaces/plugin-permissions-map';\nimport type { CalendarEvent } from './schemas/interfaces/calendar-event';\n\nexport class CapacitorCalendarWeb extends WebPlugin implements CapacitorCalendarPlugin {\n public checkPermission(_options: { alias: PluginPermission }): Promise<{ result: PermissionState }> {\n throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`);\n }\n\n public checkAllPermissions(): Promise<PluginPermissionsMap> {\n throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);\n }\n\n public requestPermission(_options: { alias: PluginPermission }): Promise<{ result: PermissionState }> {\n throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);\n }\n\n public requestAllPermissions(): Promise<PluginPermissionsMap> {\n throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);\n }\n\n public createEventWithPrompt(): Promise<{
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAmB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS7D,MAAM,OAAO,oBAAqB,SAAQ,SAAS;IAC1C,eAAe,CAAC,QAAqC;QAC1D,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACzF,CAAC;IAEM,mBAAmB;QACxB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC7F,CAAC;IAEM,iBAAiB,CAAC,QAAqC;QAC5D,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC3F,CAAC;IAEM,qBAAqB;QAC1B,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC/F,CAAC;IAEM,qBAAqB;QAC1B,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC/F,CAAC;IAEM,yBAAyB;QAC9B,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC/F,CAAC;IAEM,aAAa;QAClB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACvF,CAAC;IAEM,kBAAkB;QACvB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC5F,CAAC;IAEM,WAAW,CAAC,QAOlB;QAGC,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACrF,CAAC;IAEM,cAAc,CAAC,QAYrB;QACC,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;IAEM,uBAAuB;QAC5B,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;IAEM,iBAAiB;QACtB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;IAEM,YAAY,CAAC,QAA2B;QAC7C,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;IAEM,aAAa;QAClB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;IAEM,iBAAiB,CAAC,QAAgD;QACvE,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACxF,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { PermissionState, WebPlugin } from '@capacitor/core';\nimport { CapacitorCalendarPlugin } from './definitions';\nimport { PluginPermission } from './schemas/enums/plugin-permission';\nimport { ReminderRecurrenceRule } from './schemas/interfaces/reminder-recurrence-rule';\nimport type { Calendar } from './schemas/interfaces/calendar';\nimport type { RemindersList } from './schemas/interfaces/reminders-list';\nimport type { PluginPermissionsMap } from './schemas/interfaces/plugin-permissions-map';\nimport type { CalendarEvent } from './schemas/interfaces/calendar-event';\n\nexport class CapacitorCalendarWeb extends WebPlugin implements CapacitorCalendarPlugin {\n public checkPermission(_options: { alias: PluginPermission }): Promise<{ result: PermissionState }> {\n throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`);\n }\n\n public checkAllPermissions(): Promise<PluginPermissionsMap> {\n throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);\n }\n\n public requestPermission(_options: { alias: PluginPermission }): Promise<{ result: PermissionState }> {\n throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);\n }\n\n public requestAllPermissions(): Promise<PluginPermissionsMap> {\n throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);\n }\n\n public createEventWithPrompt(): Promise<{ result: string[] }> {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n\n public selectCalendarsWithPrompt(): Promise<{ result: Calendar[] }> {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n\n public listCalendars(): Promise<{ result: Calendar[] }> {\n throw this.unimplemented(`${this.listCalendars.name} is not implemented on the web`);\n }\n\n public getDefaultCalendar(): Promise<{ result: Calendar }> {\n throw this.unimplemented(`${this.getDefaultCalendar.name} is not implemented on the web`);\n }\n\n public createEvent(_options: {\n title: string;\n calendarId?: string;\n location?: string;\n startDate?: number;\n endDate?: number;\n isAllDay?: boolean;\n }): Promise<{\n result: string[];\n }> {\n throw this.unimplemented(`${this.createEvent.name} is not implemented on the web`);\n }\n\n public createReminder(_options: {\n title: string;\n listId?: string;\n priority?: number;\n isCompleted?: boolean;\n startDate?: number;\n dueDate?: number;\n completionDate?: number;\n notes?: string;\n url?: string;\n location?: string;\n recurrence?: ReminderRecurrenceRule;\n }): Promise<{ reminderCreated: boolean }> {\n throw this.unimplemented(`${this.createReminder.name} is not implemented on the web`);\n }\n\n public getDefaultRemindersList(): Promise<{ result: RemindersList }> {\n throw this.unimplemented(`${this.createReminder.name} is not implemented on the web`);\n }\n\n public getRemindersLists(): Promise<{ result: RemindersList[] }> {\n throw this.unimplemented(`${this.createReminder.name} is not implemented on the web`);\n }\n\n public openCalendar(_options: { date?: number }): Promise<void> {\n throw this.unimplemented(`${this.createReminder.name} is not implemented on the web`);\n }\n\n public openReminders(): Promise<void> {\n throw this.unimplemented(`${this.createReminder.name} is not implemented on the web`);\n }\n\n public listEventsInRange(_options: { startDate: number; endDate: number }): Promise<{ result: CalendarEvent[] }> {\n throw this.unimplemented(`${this.createReminder.name} is not implemented on the web`);\n }\n}\n"]}
|
|
@@ -5,7 +5,7 @@ import EventKitUI
|
|
|
5
5
|
public class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarChooserDelegate {
|
|
6
6
|
private let bridge: (any CAPBridgeProtocol)?
|
|
7
7
|
private let eventStore: EKEventStore
|
|
8
|
-
private var currentCreateEventContinuation: CheckedContinuation<
|
|
8
|
+
private var currentCreateEventContinuation: CheckedContinuation<String, any Error>?
|
|
9
9
|
private var currentSelectCalendarsContinuation: CheckedContinuation<[[String: String]], any Error>?
|
|
10
10
|
|
|
11
11
|
init(bridge: (any CAPBridgeProtocol)?, eventStore: EKEventStore) {
|
|
@@ -13,7 +13,7 @@ public class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarCho
|
|
|
13
13
|
self.eventStore = eventStore
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
public func createEventWithPrompt() async throws ->
|
|
16
|
+
public func createEventWithPrompt() async throws -> String {
|
|
17
17
|
return try await withCheckedThrowingContinuation { continuation in
|
|
18
18
|
guard let viewController = bridge?.viewController else {
|
|
19
19
|
continuation.resume(throwing: CapacitorCalendarPluginError.viewControllerUnavailable)
|
|
@@ -78,7 +78,7 @@ public class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarCho
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
public func createEvent(with parameters: EventCreationParameters) throws {
|
|
81
|
+
public func createEvent(with parameters: EventCreationParameters) throws -> String {
|
|
82
82
|
let fallbackStartDate = Date()
|
|
83
83
|
let newEvent = EKEvent(eventStore: eventStore)
|
|
84
84
|
if let calendarId = parameters.calendarId, let calendar = eventStore.calendar(withIdentifier: calendarId) {
|
|
@@ -106,8 +106,9 @@ public class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarCho
|
|
|
106
106
|
|
|
107
107
|
do {
|
|
108
108
|
try eventStore.save(newEvent, span: .thisEvent)
|
|
109
|
+
return newEvent.eventIdentifier
|
|
109
110
|
} catch {
|
|
110
|
-
throw CapacitorCalendarPluginError.
|
|
111
|
+
throw CapacitorCalendarPluginError.undefinedEvent
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
|
|
@@ -257,9 +258,14 @@ public class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarCho
|
|
|
257
258
|
) {
|
|
258
259
|
controller.dismiss(animated: true) {
|
|
259
260
|
if action == .saved {
|
|
260
|
-
|
|
261
|
+
if let event = controller.event {
|
|
262
|
+
self.currentCreateEventContinuation?.resume(returning: event.eventIdentifier)
|
|
263
|
+
} else {
|
|
264
|
+
self.currentCreateEventContinuation?.resume(throwing: CapacitorCalendarPluginError.undefinedEvent)
|
|
265
|
+
return
|
|
266
|
+
}
|
|
261
267
|
} else if action == .canceled {
|
|
262
|
-
self.currentCreateEventContinuation?.resume(
|
|
268
|
+
self.currentCreateEventContinuation?.resume(throwing: CapacitorCalendarPluginError.createEventCancelled)
|
|
263
269
|
} else {
|
|
264
270
|
self.currentCreateEventContinuation?.resume(throwing: CapacitorCalendarPluginError.unknownActionEventCreationPrompt)
|
|
265
271
|
}
|
|
@@ -127,7 +127,7 @@ public class CapacitorCalendarPlugin: CAPPlugin {
|
|
|
127
127
|
Task {
|
|
128
128
|
do {
|
|
129
129
|
let result = try await calendar.createEventWithPrompt()
|
|
130
|
-
call.resolve(["
|
|
130
|
+
call.resolve(["result": [result]])
|
|
131
131
|
} catch {
|
|
132
132
|
call.reject("[CapacitorCalendar.\(#function)] Unable to retrieve view controller")
|
|
133
133
|
return
|
|
@@ -190,8 +190,8 @@ public class CapacitorCalendarPlugin: CAPPlugin {
|
|
|
190
190
|
)
|
|
191
191
|
|
|
192
192
|
do {
|
|
193
|
-
try calendar.createEvent(with: eventParameters)
|
|
194
|
-
call.resolve(["
|
|
193
|
+
let id = try calendar.createEvent(with: eventParameters)
|
|
194
|
+
call.resolve(["result": [id]])
|
|
195
195
|
} catch {
|
|
196
196
|
call.reject("[CapacitorCalendar.\(#function)] Unable to create event")
|
|
197
197
|
return
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ebarooni/capacitor-calendar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "The Capacitor Calendar Plugin enables full calendar functionality on iOS and Android, with added reminder support for iOS devices.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|