@ebarooni/capacitor-calendar 0.2.0 → 0.3.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 CHANGED
@@ -13,13 +13,27 @@
13
13
 
14
14
  ## Table of Contents
15
15
 
16
+ - [Install](#install)
17
+ - [Support Range](#support-range)
16
18
  - [Demo](#demo--click-for-details-)
17
19
  - [MVP](#mvp)
18
- - [Support Range](#support-range)
19
- - [Install](#install)
20
20
  - [Permissions](#permissions)
21
21
  - [API](#api)
22
22
 
23
+ ## Install
24
+
25
+ ```bash
26
+ npm install @ebarooni/capacitor-calendar
27
+ npx cap sync
28
+ ```
29
+
30
+ ## Support Range
31
+
32
+ | Platform | range |
33
+ |:----------:|:------------------------------------:|
34
+ | iOS | ≥ 13 |
35
+ | Android | ≥ 4 (SDK 14 – Ice Cream Sandwich) |
36
+
23
37
  ## [Demo (click for details)](./example/README.md)
24
38
 
25
39
 
@@ -33,25 +47,13 @@ The video is just for showing the functionality, otherwise the `createEventWithP
33
47
  ## MVP
34
48
 
35
49
  - ✅ Choose calendars with prompt (only supported on iOS)
50
+ - ✅ Get list of available calendars
51
+ - ✅ Get default calendar
36
52
  - ⌛ Create calendar events without native prompts
37
53
  - ⌛️ Create reminders (only supported on iOS)
38
54
  - ⌛️ Find calendar events
39
55
  - ⌛️ Delete calendar events
40
56
 
41
- ## Support Range
42
-
43
- | Platform | range |
44
- |:----------:|:------------------------------------:|
45
- | iOS | ≥ 13 |
46
- | Android | ≥ 4 (SDK 14 – Ice Cream Sandwich) |
47
-
48
- ## Install
49
-
50
- ```bash
51
- npm install @ebarooni/capacitor-calendar
52
- npx cap sync
53
- ```
54
-
55
57
  ## Permissions
56
58
 
57
59
  To be able to use the plugin, you will need to add the required permissions to your app. The required platform-specific
@@ -70,6 +72,8 @@ permissions can be found below:
70
72
  * [`requestAllPermissions()`](#requestallpermissions)
71
73
  * [`createEventWithPrompt()`](#createeventwithprompt)
72
74
  * [`selectCalendarsWithPrompt(...)`](#selectcalendarswithprompt)
75
+ * [`listCalendars()`](#listcalendars)
76
+ * [`getDefaultCalendar()`](#getdefaultcalendar)
73
77
  * [Interfaces](#interfaces)
74
78
  * [Type Aliases](#type-aliases)
75
79
  * [Enums](#enums)
@@ -173,6 +177,32 @@ Presents a prompt to the user to select calendars. This method is available only
173
177
  --------------------
174
178
 
175
179
 
180
+ ### listCalendars()
181
+
182
+ ```typescript
183
+ listCalendars() => Promise<{ result: Calendar[]; }>
184
+ ```
185
+
186
+ Retrieves a list of calendars available on the device.
187
+
188
+ **Returns:** <code>Promise&lt;{ result: Calendar[]; }&gt;</code>
189
+
190
+ --------------------
191
+
192
+
193
+ ### getDefaultCalendar()
194
+
195
+ ```typescript
196
+ getDefaultCalendar() => Promise<{ result: Calendar; }>
197
+ ```
198
+
199
+ Retrieves the default calendar set on the device.
200
+
201
+ **Returns:** <code>Promise&lt;{ result: <a href="#calendar">Calendar</a>; }&gt;</code>
202
+
203
+ --------------------
204
+
205
+
176
206
  ### Interfaces
177
207
 
178
208
 
@@ -0,0 +1,91 @@
1
+ package dev.barooni.capacitor.calendar
2
+
3
+ import android.content.ContentResolver
4
+ import android.content.Context
5
+ import android.provider.CalendarContract
6
+ import com.getcapacitor.JSArray
7
+ import com.getcapacitor.JSObject
8
+
9
+ class CapacitorCalendar() {
10
+ var eventsCount: Int = 0
11
+
12
+ @Throws(Exception::class)
13
+ fun getTotalEventsCount(context: Context): Int {
14
+ val contentResolver: ContentResolver = context.contentResolver
15
+ val uri = CalendarContract.Events.CONTENT_URI
16
+ val projection = arrayOf(CalendarContract.Events._ID)
17
+ val cursor = contentResolver.query(uri, projection, null, null, null)
18
+ val count = cursor?.count ?: 0
19
+ cursor?.close()
20
+ return count
21
+ }
22
+
23
+ @Throws(Exception::class)
24
+ fun listCalendars(context: Context): JSArray {
25
+ val projection = arrayOf(
26
+ CalendarContract.Calendars._ID,
27
+ CalendarContract.Calendars.CALENDAR_DISPLAY_NAME
28
+ )
29
+
30
+ val calendars = JSArray()
31
+
32
+ context.contentResolver.query(
33
+ CalendarContract.Calendars.CONTENT_URI,
34
+ projection,
35
+ null,
36
+ null,
37
+ null
38
+ )?.use { cursor ->
39
+ val idColumnIndex = cursor.getColumnIndex(CalendarContract.Calendars._ID)
40
+ val nameColumnIndex = cursor.getColumnIndex(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME)
41
+
42
+ while (cursor.moveToNext()) {
43
+ val id = cursor.getLong(idColumnIndex)
44
+ val title = cursor.getString(nameColumnIndex)
45
+ val calendar = JSObject().apply {
46
+ put("id", id)
47
+ put("title", title)
48
+ }
49
+
50
+ calendars.put(calendar)
51
+ }
52
+ } ?: throw Exception("Cursor is null")
53
+
54
+ return calendars
55
+ }
56
+
57
+ @Throws(Exception::class)
58
+ fun getDefaultCalendar(context: Context): JSObject {
59
+ val projection = arrayOf(
60
+ CalendarContract.Calendars._ID,
61
+ CalendarContract.Calendars.CALENDAR_DISPLAY_NAME
62
+ )
63
+
64
+ val selection = "${CalendarContract.Calendars.IS_PRIMARY} = ?"
65
+ val selectionArgs = arrayOf("1")
66
+
67
+ context.contentResolver.query(
68
+ CalendarContract.Calendars.CONTENT_URI,
69
+ projection,
70
+ selection,
71
+ selectionArgs,
72
+ null
73
+ )?.use { cursor ->
74
+ if (cursor.moveToFirst()) {
75
+ val idColumnIndex = cursor.getColumnIndex(CalendarContract.Calendars._ID)
76
+ val nameColumnIndex = cursor.getColumnIndex(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME)
77
+ val id = cursor.getLong(idColumnIndex)
78
+ val title = cursor.getString(nameColumnIndex)
79
+
80
+ val calendarObject = JSObject().apply {
81
+ put("id", id)
82
+ put("title", title)
83
+ }
84
+ return calendarObject
85
+ } else {
86
+ throw Exception("No primary calendar found")
87
+ }
88
+ }
89
+ throw Exception("No primary calendar found")
90
+ }
91
+ }
@@ -1,13 +1,10 @@
1
1
  package dev.barooni.capacitor.calendar
2
2
 
3
3
  import android.Manifest
4
- import android.content.ContentResolver
5
- import android.content.Context
6
4
  import android.content.Intent
7
5
  import android.provider.CalendarContract
8
6
  import androidx.activity.result.ActivityResult
9
7
  import com.getcapacitor.JSObject
10
- import com.getcapacitor.PermissionState
11
8
  import com.getcapacitor.Plugin
12
9
  import com.getcapacitor.PluginCall
13
10
  import com.getcapacitor.PluginMethod
@@ -25,39 +22,64 @@ import com.getcapacitor.annotation.PermissionCallback
25
22
  strings = [
26
23
  Manifest.permission.READ_CALENDAR
27
24
  ]
25
+ ),
26
+ Permission(
27
+ alias = "writeCalendar",
28
+ strings = [
29
+ Manifest.permission.WRITE_CALENDAR
30
+ ]
28
31
  )
29
32
  ]
30
33
  )
31
- class CapacitorCalendarPlugin : Plugin() {
32
- private var totalNumberOfEvents: Int = 0
34
+ class CapacitorCalendarPlugin: Plugin() {
35
+ private var implementation = CapacitorCalendar()
33
36
 
34
37
  @PluginMethod
35
38
  fun createEventWithPrompt(call: PluginCall) {
36
39
  try {
37
- if (getPermissionState("readCalendar") != PermissionState.GRANTED) {
38
- throw Exception("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Missing readCalendar permission")
39
- } else {
40
- totalNumberOfEvents = getTotalNumberOfEvents(context)
41
- openCalendarIntent(call)
42
- }
40
+ implementation.eventsCount = implementation.getTotalEventsCount(context)
41
+ return startActivityForResult(
42
+ call,
43
+ Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI),
44
+ "openCalendarIntentActivityCallback"
45
+ )
43
46
  } catch (error: Exception) {
44
- call.reject(error.message)
47
+ call.reject("", "[CapacitorCalendar.${::openCalendarIntentActivityCallback.name}] Could not create the event")
48
+ return
49
+ }
50
+ }
51
+
52
+ @ActivityCallback
53
+ private fun openCalendarIntentActivityCallback(call: PluginCall?, result: ActivityResult) {
54
+ if (call == null) {
55
+ throw Exception("[CapacitorCalendar.${::createEventWithPrompt.name}] Call is not defined")
56
+ }
57
+ val currentEventsCount: Int = implementation.getTotalEventsCount(context)
58
+ val createEventResult = if (currentEventsCount > implementation.eventsCount) {
59
+ true
60
+ } else if (implementation.eventsCount == currentEventsCount) {
61
+ false
62
+ } else {
63
+ call.reject("", "[CapacitorCalendar.${::openCalendarIntentActivityCallback.name}] Could not create the event")
45
64
  return
46
65
  }
66
+ val ret = JSObject()
67
+ ret.put("eventCreated", createEventResult)
68
+ call.resolve(ret)
47
69
  }
48
70
 
49
71
  @PluginMethod
50
72
  fun checkPermission(call: PluginCall) {
51
73
  try {
52
74
  val permissionName = call.getString("alias")
53
- ?: throw Exception("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Permission name is not defined")
54
- val state = getPermissionState(permissionName)
55
- ?: throw Exception("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Could not determine the status of the requested permission")
75
+ ?: throw Exception("[CapacitorCalendar.${::checkPermission.name}] Permission name is not defined")
76
+ val permissionState = getPermissionState(permissionName)
77
+ ?: throw Exception("[CapacitorCalendar.${::checkPermission.name}] Could not determine the status of the requested permission")
56
78
  val ret = JSObject()
57
- ret.put("result", state)
79
+ ret.put("result", permissionState)
58
80
  call.resolve(ret)
59
81
  } catch (error: Exception) {
60
- call.reject(error.message)
82
+ call.reject("", error.message)
61
83
  return
62
84
  }
63
85
  }
@@ -65,9 +87,9 @@ class CapacitorCalendarPlugin : Plugin() {
65
87
  @PluginMethod
66
88
  fun checkAllPermissions(call: PluginCall) {
67
89
  try {
68
- checkPermissions(call)
90
+ return checkPermissions(call)
69
91
  } catch (_: Exception) {
70
- call.reject("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Could not determine the status of the requested permissions")
92
+ call.reject("", "[CapacitorCalendar.${::checkAllPermissions.name}] Could not determine the status of the requested permissions")
71
93
  return
72
94
  }
73
95
  }
@@ -75,86 +97,68 @@ class CapacitorCalendarPlugin : Plugin() {
75
97
  @PluginMethod
76
98
  fun requestPermission(call: PluginCall) {
77
99
  try {
78
- val permissionName = call.getString("alias")
79
- ?: throw Exception("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Permission name is not defined")
80
- requestPermissionForAlias(
81
- permissionName,
100
+ val alias = call.getString("alias")
101
+ ?: throw Exception("[CapacitorCalendar.${::requestPermission.name}] Permission name is not defined")
102
+ return requestPermissionForAlias(
103
+ alias,
82
104
  call,
83
- "permissionsCallback"
105
+ "requestPermissionCallback"
84
106
  )
85
107
  } catch (error: Exception) {
86
- call.reject(error.message)
108
+ call.reject("", error.message)
87
109
  return
88
110
  }
89
111
  }
90
112
 
113
+ @PermissionCallback
114
+ private fun requestPermissionCallback(call: PluginCall) {
115
+ val permissionName = call.getString("alias")
116
+ try {
117
+ val ret = JSObject()
118
+ ret.put("result", getPermissionState(permissionName))
119
+ call.resolve(ret)
120
+ } catch (_: Exception) {
121
+ throw Exception("${::requestPermissionCallback.name} Could not authorize $permissionName")
122
+ }
123
+ }
124
+
91
125
  @PluginMethod
92
126
  fun requestAllPermissions(call: PluginCall) {
93
127
  try {
94
- requestPermissions(call)
128
+ return requestPermissions(call)
95
129
  } catch (_: Exception) {
96
- call.reject("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Could not request permissions")
130
+ call.reject("", "[CapacitorCalendar.requestAllPermissions] Could not request permissions")
97
131
  return
98
132
  }
99
133
  }
100
134
 
101
135
  @PluginMethod
102
136
  fun selectCalendarsWithPrompt(call: PluginCall) {
103
- call.unimplemented("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Not implemented on Android")
137
+ call.unimplemented("[CapacitorCalendar.${::selectCalendarsWithPrompt.name}] Not implemented on Android")
104
138
  return
105
139
  }
106
140
 
107
- private fun openCalendarIntent(call: PluginCall) {
108
- val intent = Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI)
109
- startActivityForResult(call, intent, "openCalendarIntentActivityCallback")
110
- }
111
-
112
- private fun getTotalNumberOfEvents(context: Context): Int {
113
- val contentResolver: ContentResolver = context.contentResolver
114
- val uri = CalendarContract.Events.CONTENT_URI
115
- val projection = arrayOf(CalendarContract.Events._ID)
116
- val cursor = contentResolver.query(uri, projection, null, null, null)
117
- return if (cursor == null) {
118
- 0
119
- } else {
120
- try {
121
- cursor.count
122
- } catch (_: Exception) {
123
- throw Exception("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Failed to get the total events count")
124
- } finally {
125
- cursor.close()
126
- }
127
- }
128
- }
129
-
130
- @ActivityCallback
131
- private fun openCalendarIntentActivityCallback(call: PluginCall?, result: ActivityResult) {
132
- if (call == null) {
133
- throw Exception("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Call is not defined")
134
- }
135
- val ret = JSObject()
136
- val currentEventsCount: Int = getTotalNumberOfEvents(context)
137
- val createEventResult = if (currentEventsCount > totalNumberOfEvents) {
138
- true
139
- } else if (totalNumberOfEvents == currentEventsCount) {
140
- false
141
- } else {
142
- call.reject("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Could not create the event")
143
- return
141
+ @PluginMethod
142
+ fun listCalendars(call: PluginCall) {
143
+ try {
144
+ val calendars = implementation.listCalendars(context)
145
+ val ret = JSObject()
146
+ ret.put("result", calendars)
147
+ call.resolve(ret)
148
+ } catch (_: Exception) {
149
+ call.reject("", "[CapacitorCalendar.${::listCalendars.name}] Failed to get the list of calendars")
144
150
  }
145
- ret.put("eventCreated", createEventResult)
146
- call.resolve(ret)
147
151
  }
148
152
 
149
- @PermissionCallback
150
- private fun permissionsCallback(call: PluginCall) {
151
- val permissionName = call.getString("alias")
153
+ @PluginMethod
154
+ fun getDefaultCalendar(call: PluginCall) {
152
155
  try {
156
+ val primaryCalendar = implementation.getDefaultCalendar(context)
153
157
  val ret = JSObject()
154
- ret.put("result", getPermissionState(permissionName))
158
+ ret.put("result", primaryCalendar)
155
159
  call.resolve(ret)
156
160
  } catch (_: Exception) {
157
- throw Exception("${Thread.currentThread().stackTrace[1].methodName} Could not authorize $permissionName")
161
+ call.reject("", "[CapacitorCalendar.${::getDefaultCalendar.name}] No default calendar found")
158
162
  }
159
163
  }
160
164
  }
package/dist/docs.json CHANGED
@@ -184,6 +184,62 @@
184
184
  "CalendarChooserSelectionStyle"
185
185
  ],
186
186
  "slug": "selectcalendarswithprompt"
187
+ },
188
+ {
189
+ "name": "listCalendars",
190
+ "signature": "() => Promise<{ result: Calendar[]; }>",
191
+ "parameters": [],
192
+ "returns": "Promise<{ result: Calendar[]; }>",
193
+ "tags": [
194
+ {
195
+ "name": "async"
196
+ },
197
+ {
198
+ "name": "method",
199
+ "text": "listCalendars"
200
+ },
201
+ {
202
+ "name": "returns",
203
+ "text": "A promise that resolves with an array of calendars available on the device.\nEach calendar object in the array contains an ID and a title."
204
+ },
205
+ {
206
+ "name": "example",
207
+ "text": "const calendars = await listCalendars();\nconsole.log(calendars); // [{ id: '1', title: 'Work Calendar' }, { id: '2', title: 'Personal Calendar' }]"
208
+ }
209
+ ],
210
+ "docs": "Retrieves a list of calendars available on the device.",
211
+ "complexTypes": [
212
+ "Calendar"
213
+ ],
214
+ "slug": "listcalendars"
215
+ },
216
+ {
217
+ "name": "getDefaultCalendar",
218
+ "signature": "() => Promise<{ result: Calendar; }>",
219
+ "parameters": [],
220
+ "returns": "Promise<{ result: Calendar; }>",
221
+ "tags": [
222
+ {
223
+ "name": "async"
224
+ },
225
+ {
226
+ "name": "method",
227
+ "text": "getDefaultCalendar"
228
+ },
229
+ {
230
+ "name": "returns",
231
+ "text": "A promise that resolves with the default calendar set on the device.\nThe returned calendar object contains an ID and a title."
232
+ },
233
+ {
234
+ "name": "example",
235
+ "text": "const defaultCalendar = await getDefaultCalendar();\nconsole.log(defaultCalendar); // { id: '1', title: 'Default Calendar' }"
236
+ }
237
+ ],
238
+ "docs": "Retrieves the default calendar set on the device.",
239
+ "complexTypes": [
240
+ "Calendar"
241
+ ],
242
+ "slug": "getdefaultcalendar"
187
243
  }
188
244
  ],
189
245
  "properties": []
@@ -140,4 +140,32 @@ export interface CapacitorCalendarPlugin {
140
140
  }): Promise<{
141
141
  result: Calendar[];
142
142
  }>;
143
+ /**
144
+ * Retrieves a list of calendars available on the device.
145
+ *
146
+ * @async
147
+ * @method listCalendars
148
+ * @returns {Promise<{ result: Calendar[] }>} A promise that resolves with an array of calendars available on the device.
149
+ * Each calendar object in the array contains an ID and a title.
150
+ * @example
151
+ * const calendars = await listCalendars();
152
+ * console.log(calendars); // [{ id: '1', title: 'Work Calendar' }, { id: '2', title: 'Personal Calendar' }]
153
+ */
154
+ listCalendars(): Promise<{
155
+ result: Calendar[];
156
+ }>;
157
+ /**
158
+ * Retrieves the default calendar set on the device.
159
+ *
160
+ * @async
161
+ * @method getDefaultCalendar
162
+ * @returns {Promise<{ result: Calendar }>} A promise that resolves with the default calendar set on the device.
163
+ * The returned calendar object contains an ID and a title.
164
+ * @example
165
+ * const defaultCalendar = await getDefaultCalendar();
166
+ * console.log(defaultCalendar); // { id: '1', title: 'Default Calendar' }
167
+ */
168
+ getDefaultCalendar(): Promise<{
169
+ result: Calendar;
170
+ }>;
143
171
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAN,IAAY,6BAUX;AAVD,WAAY,6BAA6B;IACvC;;OAEG;IACH,qFAAM,CAAA;IAEN;;OAEG;IACH,yFAAQ,CAAA;AACV,CAAC,EAVW,6BAA6B,KAA7B,6BAA6B,QAUxC;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,2BAUX;AAVD,WAAY,2BAA2B;IACrC;;OAEG;IACH,+FAAa,CAAA;IAEb;;OAEG;IACH,mHAAuB,CAAA;AACzB,CAAC,EAVW,2BAA2B,KAA3B,2BAA2B,QAUtC","sourcesContent":["import type { PermissionState } from '@capacitor/core';\n\n/**\n * Enum representing the selection style for the calendar chooser.\n * @readonly\n * @enum\n */\nexport enum CalendarChooserSelectionStyle {\n /**\n * Allows only a single selection in the calendar chooser.\n */\n SINGLE,\n\n /**\n * Allows multiple selections in the calendar chooser.\n */\n MULTIPLE\n}\n\n/**\n * Enum representing the display styles for the calendar chooser.\n * @enum\n */\nexport enum CalendarChooserDisplayStyle {\n /**\n * Display all calendars available for selection.\n */\n ALL_CALENDARS,\n\n /**\n * Display only writable calendars available for selection.\n */\n WRITABLE_CALENDARS_ONLY\n}\n\n/**\n * Represents a calendar object with an ID and title.\n *\n * @interface Calendar\n * @property {string} id - The unique identifier of the calendar.\n * @property {string} title - The title or name of the calendar.\n */\nexport interface Calendar {\n id: string;\n title: string;\n}\n\n/**\n * Describes the permission status for reading from the calendar.\n *\n * @interface\n */\nexport interface CalendarPermissionStatus {\n readCalendar: PermissionState;\n writeCalendar: PermissionState;\n}\n\nexport interface CapacitorCalendarPlugin {\n /**\n * Checks the current authorization status of a specific permission.\n *\n * @method\n * @param options An object with the name of the permission\n * @returns {Promise&lt;{ result: PermissionState }&gt;} – 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: keyof CalendarPermissionStatus }): Promise<{ result: PermissionState }>;\n\n /**\n * Checks the current authorization status of all the required permissions for the plugin.\n *\n * @method\n * @returns {Promise&lt;CalendarPermissionStatus&gt;} – 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<CalendarPermissionStatus>;\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 * @param options An object with the name of the permission\n * @returns {Promise&lt;{ result: PermissionState }&gt;} – 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: keyof CalendarPermissionStatus }): 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 * @returns {Promise&lt;CalendarPermissionStatus&gt;} – 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<CalendarPermissionStatus>;\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 * @returns {Promise&lt;{ eventCreated: boolean }&gt;} – 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 * @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 selectedCalendars = await selectCalendarsWithPrompt();\n * console.log(selectedCalendars); // [{ id: '1', title: 'Work Calendar' }]\n * }\n */\n selectCalendarsWithPrompt(options: {\n displayStyle: CalendarChooserDisplayStyle,\n selectionStyle: CalendarChooserSelectionStyle\n }): Promise<{ result: Calendar[] }>\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAN,IAAY,6BAUX;AAVD,WAAY,6BAA6B;IACvC;;OAEG;IACH,qFAAM,CAAA;IAEN;;OAEG;IACH,yFAAQ,CAAA;AACV,CAAC,EAVW,6BAA6B,KAA7B,6BAA6B,QAUxC;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,2BAUX;AAVD,WAAY,2BAA2B;IACrC;;OAEG;IACH,+FAAa,CAAA;IAEb;;OAEG;IACH,mHAAuB,CAAA;AACzB,CAAC,EAVW,2BAA2B,KAA3B,2BAA2B,QAUtC","sourcesContent":["import type { PermissionState } from '@capacitor/core';\n\n/**\n * Enum representing the selection style for the calendar chooser.\n * @readonly\n * @enum\n */\nexport enum CalendarChooserSelectionStyle {\n /**\n * Allows only a single selection in the calendar chooser.\n */\n SINGLE,\n\n /**\n * Allows multiple selections in the calendar chooser.\n */\n MULTIPLE\n}\n\n/**\n * Enum representing the display styles for the calendar chooser.\n * @enum\n */\nexport enum CalendarChooserDisplayStyle {\n /**\n * Display all calendars available for selection.\n */\n ALL_CALENDARS,\n\n /**\n * Display only writable calendars available for selection.\n */\n WRITABLE_CALENDARS_ONLY\n}\n\n/**\n * Represents a calendar object with an ID and title.\n *\n * @interface Calendar\n * @property {string} id - The unique identifier of the calendar.\n * @property {string} title - The title or name of the calendar.\n */\nexport interface Calendar {\n id: string;\n title: string;\n}\n\n/**\n * Describes the permission status for reading from the calendar.\n *\n * @interface\n */\nexport interface CalendarPermissionStatus {\n readCalendar: PermissionState;\n writeCalendar: PermissionState;\n}\n\nexport interface CapacitorCalendarPlugin {\n /**\n * Checks the current authorization status of a specific permission.\n *\n * @method\n * @param options An object with the name of the permission\n * @returns {Promise&lt;{ result: PermissionState }&gt;} – 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: keyof CalendarPermissionStatus }): Promise<{ result: PermissionState }>;\n\n /**\n * Checks the current authorization status of all the required permissions for the plugin.\n *\n * @method\n * @returns {Promise&lt;CalendarPermissionStatus&gt;} – 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<CalendarPermissionStatus>;\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 * @param options An object with the name of the permission\n * @returns {Promise&lt;{ result: PermissionState }&gt;} – 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: keyof CalendarPermissionStatus }): 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 * @returns {Promise&lt;CalendarPermissionStatus&gt;} – 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<CalendarPermissionStatus>;\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 * @returns {Promise&lt;{ eventCreated: boolean }&gt;} – 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 * @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 selectedCalendars = await selectCalendarsWithPrompt();\n * console.log(selectedCalendars); // [{ id: '1', title: 'Work Calendar' }]\n * }\n */\n selectCalendarsWithPrompt(options: {\n displayStyle: CalendarChooserDisplayStyle,\n selectionStyle: CalendarChooserSelectionStyle\n }): Promise<{ result: Calendar[] }>\n\n\n /**\n * Retrieves a list of calendars available on the device.\n *\n * @async\n * @method listCalendars\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 calendars = await listCalendars();\n * console.log(calendars); // [{ 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 * @async\n * @method getDefaultCalendar\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 defaultCalendar = await getDefaultCalendar();\n * console.log(defaultCalendar); // { id: '1', title: 'Default Calendar' }\n */\n getDefaultCalendar(): Promise<{ result: Calendar }>;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -19,4 +19,10 @@ export declare class CapacitorCalendarWeb extends WebPlugin implements Capacitor
19
19
  selectCalendarsWithPrompt(): Promise<{
20
20
  result: Calendar[];
21
21
  }>;
22
+ listCalendars(): Promise<{
23
+ result: Calendar[];
24
+ }>;
25
+ getDefaultCalendar(): Promise<{
26
+ result: Calendar;
27
+ }>;
22
28
  }
package/dist/esm/web.js CHANGED
@@ -18,5 +18,11 @@ export class CapacitorCalendarWeb extends WebPlugin {
18
18
  selectCalendarsWithPrompt() {
19
19
  throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);
20
20
  }
21
+ listCalendars() {
22
+ throw this.unimplemented(`${this.listCalendars.name} is not implemented on the web`);
23
+ }
24
+ getDefaultCalendar() {
25
+ throw this.unimplemented(`${this.getDefaultCalendar.name} is not implemented on the web`);
26
+ }
21
27
  }
22
28
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAI3D,MAAM,OAAO,oBACT,SAAQ,SAAS;IAGV,eAAe,CAAC,QAAmD;QACtE,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,gCAAgC,CAAC,CAAA;IAC1F,CAAC;IAEM,mBAAmB;QACtB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC/F,CAAC;IAEM,iBAAiB,CAAC,QAAmD;QACxE,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC7F,CAAC;IAEM,qBAAqB;QACxB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACjG,CAAC;IAEM,qBAAqB;QACxB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACjG,CAAC;IAEM,yBAAyB;QAC5B,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACjG,CAAC;CACJ","sourcesContent":["import {PermissionState, WebPlugin} from '@capacitor/core';\n\nimport {CapacitorCalendarPlugin, CalendarPermissionStatus, Calendar} from './definitions';\n\nexport class CapacitorCalendarWeb\n extends WebPlugin\n implements CapacitorCalendarPlugin\n{\n public checkPermission(_options: { alias: keyof CalendarPermissionStatus }): Promise<{ result: PermissionState }> {\n throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`)\n }\n\n public checkAllPermissions(): Promise<CalendarPermissionStatus> {\n throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);\n }\n\n public requestPermission(_options: { alias: keyof CalendarPermissionStatus }): Promise<{ result: PermissionState }> {\n throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);\n }\n\n public requestAllPermissions(): Promise<CalendarPermissionStatus> {\n throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);\n }\n\n public createEventWithPrompt(): Promise<{ eventCreated: boolean}> {\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"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAI3D,MAAM,OAAO,oBACT,SAAQ,SAAS;IAGV,eAAe,CAAC,QAAmD;QACtE,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,gCAAgC,CAAC,CAAA;IAC1F,CAAC;IAEM,mBAAmB;QACtB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC/F,CAAC;IAEM,iBAAiB,CAAC,QAAmD;QACxE,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC7F,CAAC;IAEM,qBAAqB;QACxB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACjG,CAAC;IAEM,qBAAqB;QACxB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACjG,CAAC;IAEM,yBAAyB;QAC5B,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACjG,CAAC;IAED,aAAa;QACT,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACzF,CAAC;IAED,kBAAkB;QACd,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC9F,CAAC;CACJ","sourcesContent":["import {PermissionState, WebPlugin} from '@capacitor/core';\n\nimport {CapacitorCalendarPlugin, CalendarPermissionStatus, Calendar} from './definitions';\n\nexport class CapacitorCalendarWeb\n extends WebPlugin\n implements CapacitorCalendarPlugin\n{\n public checkPermission(_options: { alias: keyof CalendarPermissionStatus }): Promise<{ result: PermissionState }> {\n throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`)\n }\n\n public checkAllPermissions(): Promise<CalendarPermissionStatus> {\n throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);\n }\n\n public requestPermission(_options: { alias: keyof CalendarPermissionStatus }): Promise<{ result: PermissionState }> {\n throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);\n }\n\n public requestAllPermissions(): Promise<CalendarPermissionStatus> {\n throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);\n }\n\n public createEventWithPrompt(): Promise<{ eventCreated: boolean}> {\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 listCalendars(): Promise<{ result: Calendar[] }> {\n throw this.unimplemented(`${this.listCalendars.name} is not implemented on the web`);\n }\n\n getDefaultCalendar(): Promise<{ result: Calendar }> {\n throw this.unimplemented(`${this.getDefaultCalendar.name} is not implemented on the web`);\n }\n}\n"]}
@@ -59,6 +59,12 @@ class CapacitorCalendarWeb extends core.WebPlugin {
59
59
  selectCalendarsWithPrompt() {
60
60
  throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);
61
61
  }
62
+ listCalendars() {
63
+ throw this.unimplemented(`${this.listCalendars.name} is not implemented on the web`);
64
+ }
65
+ getDefaultCalendar() {
66
+ throw this.unimplemented(`${this.getDefaultCalendar.name} is not implemented on the web`);
67
+ }
62
68
  }
63
69
 
64
70
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Enum representing the selection style for the calendar chooser.\n * @readonly\n * @enum\n */\nexport var CalendarChooserSelectionStyle;\n(function (CalendarChooserSelectionStyle) {\n /**\n * Allows only a single selection in the calendar chooser.\n */\n CalendarChooserSelectionStyle[CalendarChooserSelectionStyle[\"SINGLE\"] = 0] = \"SINGLE\";\n /**\n * Allows multiple selections in the calendar chooser.\n */\n CalendarChooserSelectionStyle[CalendarChooserSelectionStyle[\"MULTIPLE\"] = 1] = \"MULTIPLE\";\n})(CalendarChooserSelectionStyle || (CalendarChooserSelectionStyle = {}));\n/**\n * Enum representing the display styles for the calendar chooser.\n * @enum\n */\nexport var CalendarChooserDisplayStyle;\n(function (CalendarChooserDisplayStyle) {\n /**\n * Display all calendars available for selection.\n */\n CalendarChooserDisplayStyle[CalendarChooserDisplayStyle[\"ALL_CALENDARS\"] = 0] = \"ALL_CALENDARS\";\n /**\n * Display only writable calendars available for selection.\n */\n CalendarChooserDisplayStyle[CalendarChooserDisplayStyle[\"WRITABLE_CALENDARS_ONLY\"] = 1] = \"WRITABLE_CALENDARS_ONLY\";\n})(CalendarChooserDisplayStyle || (CalendarChooserDisplayStyle = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorCalendar = registerPlugin('CapacitorCalendar', {\n web: () => import('./web').then(m => new m.CapacitorCalendarWeb()),\n});\nexport * from './definitions';\nexport { CapacitorCalendar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorCalendarWeb extends WebPlugin {\n checkPermission(_options) {\n throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`);\n }\n checkAllPermissions() {\n throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);\n }\n requestPermission(_options) {\n throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);\n }\n requestAllPermissions() {\n throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);\n }\n createEventWithPrompt() {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n selectCalendarsWithPrompt() {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CalendarChooserSelectionStyle","CalendarChooserDisplayStyle","registerPlugin","WebPlugin"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACWA,+CAA8B;AACzC,CAAC,UAAU,6BAA6B,EAAE;AAC1C;AACA;AACA;AACA,IAAI,6BAA6B,CAAC,6BAA6B,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;AAC1F;AACA;AACA;AACA,IAAI,6BAA6B,CAAC,6BAA6B,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;AAC9F,CAAC,EAAEA,qCAA6B,KAAKA,qCAA6B,GAAG,EAAE,CAAC,CAAC,CAAC;AAC1E;AACA;AACA;AACA;AACWC,6CAA4B;AACvC,CAAC,UAAU,2BAA2B,EAAE;AACxC;AACA;AACA;AACA,IAAI,2BAA2B,CAAC,2BAA2B,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,eAAe,CAAC;AACpG;AACA;AACA;AACA,IAAI,2BAA2B,CAAC,2BAA2B,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,GAAG,yBAAyB,CAAC;AACxH,CAAC,EAAEA,mCAA2B,KAAKA,mCAA2B,GAAG,EAAE,CAAC,CAAC;;AC7BhE,MAAC,iBAAiB,GAAGC,mBAAc,CAAC,mBAAmB,EAAE;AAC9D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;AACtE,CAAC;;ACFM,MAAM,oBAAoB,SAASC,cAAS,CAAC;AACpD,IAAI,eAAe,CAAC,QAAQ,EAAE;AAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AAC/F,KAAK;AACL,IAAI,mBAAmB,GAAG;AAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACnG,KAAK;AACL,IAAI,iBAAiB,CAAC,QAAQ,EAAE;AAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACjG,KAAK;AACL,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACrG,KAAK;AACL,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACrG,KAAK;AACL,IAAI,yBAAyB,GAAG;AAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACrG,KAAK;AACL;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Enum representing the selection style for the calendar chooser.\n * @readonly\n * @enum\n */\nexport var CalendarChooserSelectionStyle;\n(function (CalendarChooserSelectionStyle) {\n /**\n * Allows only a single selection in the calendar chooser.\n */\n CalendarChooserSelectionStyle[CalendarChooserSelectionStyle[\"SINGLE\"] = 0] = \"SINGLE\";\n /**\n * Allows multiple selections in the calendar chooser.\n */\n CalendarChooserSelectionStyle[CalendarChooserSelectionStyle[\"MULTIPLE\"] = 1] = \"MULTIPLE\";\n})(CalendarChooserSelectionStyle || (CalendarChooserSelectionStyle = {}));\n/**\n * Enum representing the display styles for the calendar chooser.\n * @enum\n */\nexport var CalendarChooserDisplayStyle;\n(function (CalendarChooserDisplayStyle) {\n /**\n * Display all calendars available for selection.\n */\n CalendarChooserDisplayStyle[CalendarChooserDisplayStyle[\"ALL_CALENDARS\"] = 0] = \"ALL_CALENDARS\";\n /**\n * Display only writable calendars available for selection.\n */\n CalendarChooserDisplayStyle[CalendarChooserDisplayStyle[\"WRITABLE_CALENDARS_ONLY\"] = 1] = \"WRITABLE_CALENDARS_ONLY\";\n})(CalendarChooserDisplayStyle || (CalendarChooserDisplayStyle = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorCalendar = registerPlugin('CapacitorCalendar', {\n web: () => import('./web').then(m => new m.CapacitorCalendarWeb()),\n});\nexport * from './definitions';\nexport { CapacitorCalendar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorCalendarWeb extends WebPlugin {\n checkPermission(_options) {\n throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`);\n }\n checkAllPermissions() {\n throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);\n }\n requestPermission(_options) {\n throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);\n }\n requestAllPermissions() {\n throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);\n }\n createEventWithPrompt() {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n selectCalendarsWithPrompt() {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n listCalendars() {\n throw this.unimplemented(`${this.listCalendars.name} is not implemented on the web`);\n }\n getDefaultCalendar() {\n throw this.unimplemented(`${this.getDefaultCalendar.name} is not implemented on the web`);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CalendarChooserSelectionStyle","CalendarChooserDisplayStyle","registerPlugin","WebPlugin"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACWA,+CAA8B;AACzC,CAAC,UAAU,6BAA6B,EAAE;AAC1C;AACA;AACA;AACA,IAAI,6BAA6B,CAAC,6BAA6B,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;AAC1F;AACA;AACA;AACA,IAAI,6BAA6B,CAAC,6BAA6B,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;AAC9F,CAAC,EAAEA,qCAA6B,KAAKA,qCAA6B,GAAG,EAAE,CAAC,CAAC,CAAC;AAC1E;AACA;AACA;AACA;AACWC,6CAA4B;AACvC,CAAC,UAAU,2BAA2B,EAAE;AACxC;AACA;AACA;AACA,IAAI,2BAA2B,CAAC,2BAA2B,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,eAAe,CAAC;AACpG;AACA;AACA;AACA,IAAI,2BAA2B,CAAC,2BAA2B,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,GAAG,yBAAyB,CAAC;AACxH,CAAC,EAAEA,mCAA2B,KAAKA,mCAA2B,GAAG,EAAE,CAAC,CAAC;;AC7BhE,MAAC,iBAAiB,GAAGC,mBAAc,CAAC,mBAAmB,EAAE;AAC9D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;AACtE,CAAC;;ACFM,MAAM,oBAAoB,SAASC,cAAS,CAAC;AACpD,IAAI,eAAe,CAAC,QAAQ,EAAE;AAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AAC/F,KAAK;AACL,IAAI,mBAAmB,GAAG;AAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACnG,KAAK;AACL,IAAI,iBAAiB,CAAC,QAAQ,EAAE;AAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACjG,KAAK;AACL,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACrG,KAAK;AACL,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACrG,KAAK;AACL,IAAI,yBAAyB,GAAG;AAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACrG,KAAK;AACL,IAAI,aAAa,GAAG;AACpB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AAC7F,KAAK;AACL,IAAI,kBAAkB,GAAG;AACzB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AAClG,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -56,6 +56,12 @@ var capacitorCapacitorCalendar = (function (exports, core) {
56
56
  selectCalendarsWithPrompt() {
57
57
  throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);
58
58
  }
59
+ listCalendars() {
60
+ throw this.unimplemented(`${this.listCalendars.name} is not implemented on the web`);
61
+ }
62
+ getDefaultCalendar() {
63
+ throw this.unimplemented(`${this.getDefaultCalendar.name} is not implemented on the web`);
64
+ }
59
65
  }
60
66
 
61
67
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Enum representing the selection style for the calendar chooser.\n * @readonly\n * @enum\n */\nexport var CalendarChooserSelectionStyle;\n(function (CalendarChooserSelectionStyle) {\n /**\n * Allows only a single selection in the calendar chooser.\n */\n CalendarChooserSelectionStyle[CalendarChooserSelectionStyle[\"SINGLE\"] = 0] = \"SINGLE\";\n /**\n * Allows multiple selections in the calendar chooser.\n */\n CalendarChooserSelectionStyle[CalendarChooserSelectionStyle[\"MULTIPLE\"] = 1] = \"MULTIPLE\";\n})(CalendarChooserSelectionStyle || (CalendarChooserSelectionStyle = {}));\n/**\n * Enum representing the display styles for the calendar chooser.\n * @enum\n */\nexport var CalendarChooserDisplayStyle;\n(function (CalendarChooserDisplayStyle) {\n /**\n * Display all calendars available for selection.\n */\n CalendarChooserDisplayStyle[CalendarChooserDisplayStyle[\"ALL_CALENDARS\"] = 0] = \"ALL_CALENDARS\";\n /**\n * Display only writable calendars available for selection.\n */\n CalendarChooserDisplayStyle[CalendarChooserDisplayStyle[\"WRITABLE_CALENDARS_ONLY\"] = 1] = \"WRITABLE_CALENDARS_ONLY\";\n})(CalendarChooserDisplayStyle || (CalendarChooserDisplayStyle = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorCalendar = registerPlugin('CapacitorCalendar', {\n web: () => import('./web').then(m => new m.CapacitorCalendarWeb()),\n});\nexport * from './definitions';\nexport { CapacitorCalendar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorCalendarWeb extends WebPlugin {\n checkPermission(_options) {\n throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`);\n }\n checkAllPermissions() {\n throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);\n }\n requestPermission(_options) {\n throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);\n }\n requestAllPermissions() {\n throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);\n }\n createEventWithPrompt() {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n selectCalendarsWithPrompt() {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CalendarChooserSelectionStyle","CalendarChooserDisplayStyle","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AACWA,mDAA8B;IACzC,CAAC,UAAU,6BAA6B,EAAE;IAC1C;IACA;IACA;IACA,IAAI,6BAA6B,CAAC,6BAA6B,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IAC1F;IACA;IACA;IACA,IAAI,6BAA6B,CAAC,6BAA6B,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IAC9F,CAAC,EAAEA,qCAA6B,KAAKA,qCAA6B,GAAG,EAAE,CAAC,CAAC,CAAC;IAC1E;IACA;IACA;IACA;AACWC,iDAA4B;IACvC,CAAC,UAAU,2BAA2B,EAAE;IACxC;IACA;IACA;IACA,IAAI,2BAA2B,CAAC,2BAA2B,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,eAAe,CAAC;IACpG;IACA;IACA;IACA,IAAI,2BAA2B,CAAC,2BAA2B,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,GAAG,yBAAyB,CAAC;IACxH,CAAC,EAAEA,mCAA2B,KAAKA,mCAA2B,GAAG,EAAE,CAAC,CAAC;;AC7BhE,UAAC,iBAAiB,GAAGC,mBAAc,CAAC,mBAAmB,EAAE;IAC9D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;IACtE,CAAC;;ICFM,MAAM,oBAAoB,SAASC,cAAS,CAAC;IACpD,IAAI,eAAe,CAAC,QAAQ,EAAE;IAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IAC/F,KAAK;IACL,IAAI,mBAAmB,GAAG;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACnG,KAAK;IACL,IAAI,iBAAiB,CAAC,QAAQ,EAAE;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACjG,KAAK;IACL,IAAI,qBAAqB,GAAG;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACrG,KAAK;IACL,IAAI,qBAAqB,GAAG;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACrG,KAAK;IACL,IAAI,yBAAyB,GAAG;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACrG,KAAK;IACL;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Enum representing the selection style for the calendar chooser.\n * @readonly\n * @enum\n */\nexport var CalendarChooserSelectionStyle;\n(function (CalendarChooserSelectionStyle) {\n /**\n * Allows only a single selection in the calendar chooser.\n */\n CalendarChooserSelectionStyle[CalendarChooserSelectionStyle[\"SINGLE\"] = 0] = \"SINGLE\";\n /**\n * Allows multiple selections in the calendar chooser.\n */\n CalendarChooserSelectionStyle[CalendarChooserSelectionStyle[\"MULTIPLE\"] = 1] = \"MULTIPLE\";\n})(CalendarChooserSelectionStyle || (CalendarChooserSelectionStyle = {}));\n/**\n * Enum representing the display styles for the calendar chooser.\n * @enum\n */\nexport var CalendarChooserDisplayStyle;\n(function (CalendarChooserDisplayStyle) {\n /**\n * Display all calendars available for selection.\n */\n CalendarChooserDisplayStyle[CalendarChooserDisplayStyle[\"ALL_CALENDARS\"] = 0] = \"ALL_CALENDARS\";\n /**\n * Display only writable calendars available for selection.\n */\n CalendarChooserDisplayStyle[CalendarChooserDisplayStyle[\"WRITABLE_CALENDARS_ONLY\"] = 1] = \"WRITABLE_CALENDARS_ONLY\";\n})(CalendarChooserDisplayStyle || (CalendarChooserDisplayStyle = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorCalendar = registerPlugin('CapacitorCalendar', {\n web: () => import('./web').then(m => new m.CapacitorCalendarWeb()),\n});\nexport * from './definitions';\nexport { CapacitorCalendar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorCalendarWeb extends WebPlugin {\n checkPermission(_options) {\n throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`);\n }\n checkAllPermissions() {\n throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);\n }\n requestPermission(_options) {\n throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);\n }\n requestAllPermissions() {\n throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);\n }\n createEventWithPrompt() {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n selectCalendarsWithPrompt() {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n listCalendars() {\n throw this.unimplemented(`${this.listCalendars.name} is not implemented on the web`);\n }\n getDefaultCalendar() {\n throw this.unimplemented(`${this.getDefaultCalendar.name} is not implemented on the web`);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CalendarChooserSelectionStyle","CalendarChooserDisplayStyle","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AACWA,mDAA8B;IACzC,CAAC,UAAU,6BAA6B,EAAE;IAC1C;IACA;IACA;IACA,IAAI,6BAA6B,CAAC,6BAA6B,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;IAC1F;IACA;IACA;IACA,IAAI,6BAA6B,CAAC,6BAA6B,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IAC9F,CAAC,EAAEA,qCAA6B,KAAKA,qCAA6B,GAAG,EAAE,CAAC,CAAC,CAAC;IAC1E;IACA;IACA;IACA;AACWC,iDAA4B;IACvC,CAAC,UAAU,2BAA2B,EAAE;IACxC;IACA;IACA;IACA,IAAI,2BAA2B,CAAC,2BAA2B,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,eAAe,CAAC;IACpG;IACA;IACA;IACA,IAAI,2BAA2B,CAAC,2BAA2B,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,GAAG,yBAAyB,CAAC;IACxH,CAAC,EAAEA,mCAA2B,KAAKA,mCAA2B,GAAG,EAAE,CAAC,CAAC;;AC7BhE,UAAC,iBAAiB,GAAGC,mBAAc,CAAC,mBAAmB,EAAE;IAC9D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;IACtE,CAAC;;ICFM,MAAM,oBAAoB,SAASC,cAAS,CAAC;IACpD,IAAI,eAAe,CAAC,QAAQ,EAAE;IAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IAC/F,KAAK;IACL,IAAI,mBAAmB,GAAG;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACnG,KAAK;IACL,IAAI,iBAAiB,CAAC,QAAQ,EAAE;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACjG,KAAK;IACL,IAAI,qBAAqB,GAAG;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACrG,KAAK;IACL,IAAI,qBAAqB,GAAG;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACrG,KAAK;IACL,IAAI,yBAAyB,GAAG;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACrG,KAAK;IACL,IAAI,aAAa,GAAG;IACpB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IAC7F,KAAK;IACL,IAAI,kBAAkB,GAAG;IACzB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IAClG,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -57,6 +57,22 @@ public class CapacitorCalendar: NSObject, EKEventEditViewDelegate, EKCalendarCho
57
57
  }
58
58
  }
59
59
 
60
+ public func listCalendars() -> [[String: String]] {
61
+ return convertEKCalendarsToDictionaries(calendars: Set(eventStore.calendars(for: .event)))
62
+ }
63
+
64
+ public func getDefaultCalendar() throws -> [String: String] {
65
+ let defaultCalendar = eventStore.defaultCalendarForNewEvents
66
+ if (defaultCalendar != nil) {
67
+ return [
68
+ "id": defaultCalendar!.calendarIdentifier,
69
+ "title": defaultCalendar!.title
70
+ ]
71
+ } else {
72
+ throw CapacitorCalendarPluginError.noDefaultCalendar
73
+ }
74
+ }
75
+
60
76
  public func checkAllPermissions() async throws -> [String: String] {
61
77
  return try await withCheckedThrowingContinuation { continuation in
62
78
  var permissionsState: [String: String]
@@ -10,4 +10,6 @@ CAP_PLUGIN(CapacitorCalendarPlugin, "CapacitorCalendar",
10
10
  CAP_PLUGIN_METHOD(requestPermission, CAPPluginReturnPromise);
11
11
  CAP_PLUGIN_METHOD(requestAllPermissions, CAPPluginReturnPromise);
12
12
  CAP_PLUGIN_METHOD(selectCalendarsWithPrompt, CAPPluginReturnPromise);
13
+ CAP_PLUGIN_METHOD(listCalendars, CAPPluginReturnPromise);
14
+ CAP_PLUGIN_METHOD(getDefaultCalendar, CAPPluginReturnPromise);
13
15
  )
@@ -129,4 +129,16 @@ public class CapacitorCalendarPlugin: CAPPlugin {
129
129
  }
130
130
  }
131
131
  }
132
+
133
+ @objc public func listCalendars(_ call: CAPPluginCall) {
134
+ call.resolve(["result": implementation.listCalendars()])
135
+ }
136
+
137
+ @objc public func getDefaultCalendar(_ call: CAPPluginCall) {
138
+ do {
139
+ try call.resolve(["result": implementation.getDefaultCalendar()])
140
+ } catch {
141
+ call.reject("[CapacitorCalendar.\(#function)] No default calendar was found")
142
+ }
143
+ }
132
144
  }
@@ -14,4 +14,5 @@ public enum CapacitorCalendarPluginError: Error {
14
14
  case viewControllerUnavailable
15
15
  case unknownActionEventCreationPrompt
16
16
  case canceledCalendarsSelectionPrompt
17
+ case noDefaultCalendar
17
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebarooni/capacitor-calendar",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "The Capacitor Calendar Plugin exposes functionalities for interacting with the calendar of iOS and Android devices.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",