@ebarooni/capacitor-calendar 0.1.0 → 0.2.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 +61 -29
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +12 -11
- package/dist/docs.json +110 -19
- package/dist/esm/definitions.d.ts +60 -11
- package/dist/esm/definitions.js +28 -10
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +5 -2
- package/dist/esm/web.js +3 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +31 -10
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +31 -10
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Calendar.swift +14 -0
- package/ios/Plugin/CapacitorCalendar.swift +162 -138
- package/ios/Plugin/CapacitorCalendarPlugin.m +1 -0
- package/ios/Plugin/CapacitorCalendarPlugin.swift +106 -7
- package/ios/Plugin/CapacitorCalendarPluginError.swift +17 -0
- package/ios/Plugin/PermissionState.swift +16 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,19 +7,14 @@
|
|
|
7
7
|
</em>
|
|
8
8
|
</p>
|
|
9
9
|
<p align="center">
|
|
10
|
-
<a href="https://capacitor-calendar.
|
|
10
|
+
<a href="https://capacitor-calendar.pages.dev/"><strong>https://capacitor-calendar.pages.dev</strong></a>
|
|
11
11
|
<br>
|
|
12
12
|
</p>
|
|
13
|
-
<p align="center">
|
|
14
|
-
<a href="https://app.netlify.com/sites/capacitor-calendar/deploys">
|
|
15
|
-
<img src="https://api.netlify.com/api/v1/badges/0f1a6d09-740f-4f52-889c-38ff57d11380/deploy-status" alt="Netlify Status">
|
|
16
|
-
</a>
|
|
17
|
-
</p>
|
|
18
13
|
|
|
19
14
|
## Table of Contents
|
|
20
15
|
|
|
21
16
|
- [Demo](#demo--click-for-details-)
|
|
22
|
-
- [
|
|
17
|
+
- [MVP](#mvp)
|
|
23
18
|
- [Support Range](#support-range)
|
|
24
19
|
- [Install](#install)
|
|
25
20
|
- [Permissions](#permissions)
|
|
@@ -35,12 +30,13 @@
|
|
|
35
30
|
On iOS, `readCalendar` permission is not needed when you are creating an event using the native prompt.
|
|
36
31
|
The video is just for showing the functionality, otherwise the `createEventWithPrompt` method works without the `readCalendar` authorization.
|
|
37
32
|
|
|
38
|
-
##
|
|
33
|
+
## MVP
|
|
39
34
|
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
35
|
+
- ✅ Choose calendars with prompt (only supported on iOS)
|
|
36
|
+
- ⌛ Create calendar events without native prompts
|
|
37
|
+
- ⌛️ Create reminders (only supported on iOS)
|
|
38
|
+
- ⌛️ Find calendar events
|
|
39
|
+
- ⌛️ Delete calendar events
|
|
44
40
|
|
|
45
41
|
## Support Range
|
|
46
42
|
|
|
@@ -73,6 +69,7 @@ permissions can be found below:
|
|
|
73
69
|
* [`requestPermission(...)`](#requestpermission)
|
|
74
70
|
* [`requestAllPermissions()`](#requestallpermissions)
|
|
75
71
|
* [`createEventWithPrompt()`](#createeventwithprompt)
|
|
72
|
+
* [`selectCalendarsWithPrompt(...)`](#selectcalendarswithprompt)
|
|
76
73
|
* [Interfaces](#interfaces)
|
|
77
74
|
* [Type Aliases](#type-aliases)
|
|
78
75
|
* [Enums](#enums)
|
|
@@ -90,9 +87,9 @@ checkPermission(options: { alias: keyof CalendarPermissionStatus; }) => Promise<
|
|
|
90
87
|
|
|
91
88
|
Checks the current authorization status of a specific permission.
|
|
92
89
|
|
|
93
|
-
| Param | Type
|
|
94
|
-
| ------------- |
|
|
95
|
-
| **`options`** | <code>{ alias:
|
|
90
|
+
| Param | Type | Description |
|
|
91
|
+
| ------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------- |
|
|
92
|
+
| **`options`** | <code>{ alias: keyof <a href="#calendarpermissionstatus">CalendarPermissionStatus</a>; }</code> | An object with the name of the permission |
|
|
96
93
|
|
|
97
94
|
**Returns:** <code>Promise<{ result: <a href="#permissionstate">PermissionState</a>; }></code>
|
|
98
95
|
|
|
@@ -121,9 +118,9 @@ requestPermission(options: { alias: keyof CalendarPermissionStatus; }) => Promis
|
|
|
121
118
|
Requests authorization to a specific permission, if not already granted.
|
|
122
119
|
If the permission is already granted, it will directly return the status.
|
|
123
120
|
|
|
124
|
-
| Param | Type
|
|
125
|
-
| ------------- |
|
|
126
|
-
| **`options`** | <code>{ alias:
|
|
121
|
+
| Param | Type | Description |
|
|
122
|
+
| ------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------- |
|
|
123
|
+
| **`options`** | <code>{ alias: keyof <a href="#calendarpermissionstatus">CalendarPermissionStatus</a>; }</code> | An object with the name of the permission |
|
|
127
124
|
|
|
128
125
|
**Returns:** <code>Promise<{ result: <a href="#permissionstate">PermissionState</a>; }></code>
|
|
129
126
|
|
|
@@ -146,7 +143,7 @@ Requests authorization to all the required permissions for the plugin, if they h
|
|
|
146
143
|
### createEventWithPrompt()
|
|
147
144
|
|
|
148
145
|
```typescript
|
|
149
|
-
createEventWithPrompt() => Promise<{
|
|
146
|
+
createEventWithPrompt() => Promise<{ eventCreated: boolean; }>
|
|
150
147
|
```
|
|
151
148
|
|
|
152
149
|
Creates an event in the calendar by using the native calendar.
|
|
@@ -154,7 +151,24 @@ On iOS opens a native sheet and on Android opens an intent.
|
|
|
154
151
|
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.
|
|
155
152
|
On Android, the user has to authorize for read access.
|
|
156
153
|
|
|
157
|
-
**Returns:** <code>Promise<{
|
|
154
|
+
**Returns:** <code>Promise<{ eventCreated: boolean; }></code>
|
|
155
|
+
|
|
156
|
+
--------------------
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
### selectCalendarsWithPrompt(...)
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
selectCalendarsWithPrompt(options: { displayStyle: CalendarChooserDisplayStyle; selectionStyle: CalendarChooserSelectionStyle; }) => Promise<{ result: Calendar[]; }>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Presents a prompt to the user to select calendars. This method is available only on iOS.
|
|
166
|
+
|
|
167
|
+
| Param | Type | Description |
|
|
168
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
169
|
+
| **`options`** | <code>{ displayStyle: <a href="#calendarchooserdisplaystyle">CalendarChooserDisplayStyle</a>; selectionStyle: <a href="#calendarchooserselectionstyle">CalendarChooserSelectionStyle</a>; }</code> | - Options for customizing the display and selection styles of the calendar chooser. |
|
|
170
|
+
|
|
171
|
+
**Returns:** <code>Promise<{ result: Calendar[]; }></code>
|
|
158
172
|
|
|
159
173
|
--------------------
|
|
160
174
|
|
|
@@ -166,9 +180,20 @@ On Android, the user has to authorize for read access.
|
|
|
166
180
|
|
|
167
181
|
Describes the permission status for reading from the calendar.
|
|
168
182
|
|
|
169
|
-
| Prop
|
|
170
|
-
|
|
|
171
|
-
| **`readCalendar`**
|
|
183
|
+
| Prop | Type |
|
|
184
|
+
| ------------------- | ----------------------------------------------------------- |
|
|
185
|
+
| **`readCalendar`** | <code><a href="#permissionstate">PermissionState</a></code> |
|
|
186
|
+
| **`writeCalendar`** | <code><a href="#permissionstate">PermissionState</a></code> |
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
#### Calendar
|
|
190
|
+
|
|
191
|
+
Represents a calendar object with an ID and title.
|
|
192
|
+
|
|
193
|
+
| Prop | Type |
|
|
194
|
+
| ----------- | ------------------- |
|
|
195
|
+
| **`id`** | <code>string</code> |
|
|
196
|
+
| **`title`** | <code>string</code> |
|
|
172
197
|
|
|
173
198
|
|
|
174
199
|
### Type Aliases
|
|
@@ -182,12 +207,19 @@ Describes the permission status for reading from the calendar.
|
|
|
182
207
|
### Enums
|
|
183
208
|
|
|
184
209
|
|
|
185
|
-
####
|
|
210
|
+
#### CalendarChooserDisplayStyle
|
|
211
|
+
|
|
212
|
+
| Members | Description |
|
|
213
|
+
| ----------------------------- | -------------------------------------------------------- |
|
|
214
|
+
| **`ALL_CALENDARS`** | Display all calendars available for selection. |
|
|
215
|
+
| **`WRITABLE_CALENDARS_ONLY`** | Display only writable calendars available for selection. |
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
#### CalendarChooserSelectionStyle
|
|
186
219
|
|
|
187
|
-
| Members |
|
|
188
|
-
| -------------- |
|
|
189
|
-
| **`
|
|
190
|
-
| **`
|
|
191
|
-
| **`Error`** | <code>'error'</code> |
|
|
220
|
+
| Members | Description |
|
|
221
|
+
| -------------- | ------------------------------------------------------- |
|
|
222
|
+
| **`SINGLE`** | Allows only a single selection in the calendar chooser. |
|
|
223
|
+
| **`MULTIPLE`** | Allows multiple selections in the calendar chooser. |
|
|
192
224
|
|
|
193
225
|
</docgen-api>
|
|
@@ -29,12 +29,6 @@ import com.getcapacitor.annotation.PermissionCallback
|
|
|
29
29
|
]
|
|
30
30
|
)
|
|
31
31
|
class CapacitorCalendarPlugin : Plugin() {
|
|
32
|
-
private enum class CalendarEventActionResult(val value: String) {
|
|
33
|
-
SAVED("saved"),
|
|
34
|
-
CANCELED("canceled"),
|
|
35
|
-
ERROR("error")
|
|
36
|
-
}
|
|
37
|
-
|
|
38
32
|
private var totalNumberOfEvents: Int = 0
|
|
39
33
|
|
|
40
34
|
@PluginMethod
|
|
@@ -104,6 +98,12 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
104
98
|
}
|
|
105
99
|
}
|
|
106
100
|
|
|
101
|
+
@PluginMethod
|
|
102
|
+
fun selectCalendarsWithPrompt(call: PluginCall) {
|
|
103
|
+
call.unimplemented("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Not implemented on Android")
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
107
|
private fun openCalendarIntent(call: PluginCall) {
|
|
108
108
|
val intent = Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI)
|
|
109
109
|
startActivityForResult(call, intent, "openCalendarIntentActivityCallback")
|
|
@@ -134,14 +134,15 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
134
134
|
}
|
|
135
135
|
val ret = JSObject()
|
|
136
136
|
val currentEventsCount: Int = getTotalNumberOfEvents(context)
|
|
137
|
-
val
|
|
138
|
-
|
|
137
|
+
val createEventResult = if (currentEventsCount > totalNumberOfEvents) {
|
|
138
|
+
true
|
|
139
139
|
} else if (totalNumberOfEvents == currentEventsCount) {
|
|
140
|
-
|
|
140
|
+
false
|
|
141
141
|
} else {
|
|
142
|
-
|
|
142
|
+
call.reject("[CapacitorCalendar.${Thread.currentThread().stackTrace[1].methodName}] Could not create the event")
|
|
143
|
+
return
|
|
143
144
|
}
|
|
144
|
-
ret.put("
|
|
145
|
+
ret.put("eventCreated", createEventResult)
|
|
145
146
|
call.resolve(ret)
|
|
146
147
|
}
|
|
147
148
|
|
package/dist/docs.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
{
|
|
13
13
|
"name": "options",
|
|
14
14
|
"docs": "An object with the name of the permission",
|
|
15
|
-
"type": "{ alias:
|
|
15
|
+
"type": "{ alias: keyof CalendarPermissionStatus; }"
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
18
|
"returns": "Promise<{ result: PermissionState; }>",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
{
|
|
72
72
|
"name": "options",
|
|
73
73
|
"docs": "An object with the name of the permission",
|
|
74
|
-
"type": "{ alias:
|
|
74
|
+
"type": "{ alias: keyof CalendarPermissionStatus; }"
|
|
75
75
|
}
|
|
76
76
|
],
|
|
77
77
|
"returns": "Promise<{ result: PermissionState; }>",
|
|
@@ -125,27 +125,65 @@
|
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
127
|
"name": "createEventWithPrompt",
|
|
128
|
-
"signature": "() => Promise<{
|
|
128
|
+
"signature": "() => Promise<{ eventCreated: boolean; }>",
|
|
129
129
|
"parameters": [],
|
|
130
|
-
"returns": "Promise<{
|
|
130
|
+
"returns": "Promise<{ eventCreated: boolean; }>",
|
|
131
131
|
"tags": [
|
|
132
132
|
{
|
|
133
133
|
"name": "method"
|
|
134
134
|
},
|
|
135
135
|
{
|
|
136
136
|
"name": "returns",
|
|
137
|
-
"text": ";{
|
|
137
|
+
"text": ";{ eventCreated: boolean }>} – A promise that resolves with the result of the action."
|
|
138
138
|
},
|
|
139
139
|
{
|
|
140
140
|
"name": "example",
|
|
141
|
-
"text": "let result: CalendarEventActionResult;\nif (capacitor.getPlatform() === 'android') {\n const readCalendarStatus = 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}"
|
|
141
|
+
"text": "let result: CalendarEventActionResult;\nif (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}"
|
|
142
142
|
}
|
|
143
143
|
],
|
|
144
144
|
"docs": "Creates an event in the calendar by using the native calendar.\nOn iOS opens a native sheet and on Android opens an intent.\nThis 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.\nOn Android, the user has to authorize for read access.",
|
|
145
|
+
"complexTypes": [],
|
|
146
|
+
"slug": "createeventwithprompt"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"name": "selectCalendarsWithPrompt",
|
|
150
|
+
"signature": "(options: { displayStyle: CalendarChooserDisplayStyle; selectionStyle: CalendarChooserSelectionStyle; }) => Promise<{ result: Calendar[]; }>",
|
|
151
|
+
"parameters": [
|
|
152
|
+
{
|
|
153
|
+
"name": "options",
|
|
154
|
+
"docs": "- Options for customizing the display and selection styles of the calendar chooser.",
|
|
155
|
+
"type": "{ displayStyle: CalendarChooserDisplayStyle; selectionStyle: CalendarChooserSelectionStyle; }"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"returns": "Promise<{ result: Calendar[]; }>",
|
|
159
|
+
"tags": [
|
|
160
|
+
{
|
|
161
|
+
"name": "method",
|
|
162
|
+
"text": "selectCalendarsWithPrompt"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "param",
|
|
166
|
+
"text": "options - Options for customizing the display and selection styles of the calendar chooser."
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"name": "async"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"name": "returns",
|
|
173
|
+
"text": "A promise that resolves with an array of selected calendars,\nwhere each calendar object contains an ID and a title."
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "example",
|
|
177
|
+
"text": "if (capacitor.getPlatform() === 'ios') {\n const selectedCalendars = await selectCalendarsWithPrompt();\n console.log(selectedCalendars); // [{ id: '1', title: 'Work Calendar' }]\n}"
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"docs": "Presents a prompt to the user to select calendars. This method is available only on iOS.",
|
|
145
181
|
"complexTypes": [
|
|
146
|
-
"
|
|
182
|
+
"Calendar",
|
|
183
|
+
"CalendarChooserDisplayStyle",
|
|
184
|
+
"CalendarChooserSelectionStyle"
|
|
147
185
|
],
|
|
148
|
-
"slug": "
|
|
186
|
+
"slug": "selectcalendarswithprompt"
|
|
149
187
|
}
|
|
150
188
|
],
|
|
151
189
|
"properties": []
|
|
@@ -170,32 +208,85 @@
|
|
|
170
208
|
"PermissionState"
|
|
171
209
|
],
|
|
172
210
|
"type": "PermissionState"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"name": "writeCalendar",
|
|
214
|
+
"tags": [],
|
|
215
|
+
"docs": "",
|
|
216
|
+
"complexTypes": [
|
|
217
|
+
"PermissionState"
|
|
218
|
+
],
|
|
219
|
+
"type": "PermissionState"
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"name": "Calendar",
|
|
225
|
+
"slug": "calendar",
|
|
226
|
+
"docs": "Represents a calendar object with an ID and title.",
|
|
227
|
+
"tags": [
|
|
228
|
+
{
|
|
229
|
+
"text": "Calendar",
|
|
230
|
+
"name": "interface"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"text": "{string} id - The unique identifier of the calendar.",
|
|
234
|
+
"name": "property"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"text": "{string} title - The title or name of the calendar.",
|
|
238
|
+
"name": "property"
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
"methods": [],
|
|
242
|
+
"properties": [
|
|
243
|
+
{
|
|
244
|
+
"name": "id",
|
|
245
|
+
"tags": [],
|
|
246
|
+
"docs": "",
|
|
247
|
+
"complexTypes": [],
|
|
248
|
+
"type": "string"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"name": "title",
|
|
252
|
+
"tags": [],
|
|
253
|
+
"docs": "",
|
|
254
|
+
"complexTypes": [],
|
|
255
|
+
"type": "string"
|
|
173
256
|
}
|
|
174
257
|
]
|
|
175
258
|
}
|
|
176
259
|
],
|
|
177
260
|
"enums": [
|
|
178
261
|
{
|
|
179
|
-
"name": "
|
|
180
|
-
"slug": "
|
|
262
|
+
"name": "CalendarChooserDisplayStyle",
|
|
263
|
+
"slug": "calendarchooserdisplaystyle",
|
|
181
264
|
"members": [
|
|
182
265
|
{
|
|
183
|
-
"name": "
|
|
184
|
-
"value": "'saved'",
|
|
266
|
+
"name": "ALL_CALENDARS",
|
|
185
267
|
"tags": [],
|
|
186
|
-
"docs": ""
|
|
268
|
+
"docs": "Display all calendars available for selection."
|
|
187
269
|
},
|
|
188
270
|
{
|
|
189
|
-
"name": "
|
|
190
|
-
"
|
|
271
|
+
"name": "WRITABLE_CALENDARS_ONLY",
|
|
272
|
+
"tags": [],
|
|
273
|
+
"docs": "Display only writable calendars available for selection."
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"name": "CalendarChooserSelectionStyle",
|
|
279
|
+
"slug": "calendarchooserselectionstyle",
|
|
280
|
+
"members": [
|
|
281
|
+
{
|
|
282
|
+
"name": "SINGLE",
|
|
191
283
|
"tags": [],
|
|
192
|
-
"docs": ""
|
|
284
|
+
"docs": "Allows only a single selection in the calendar chooser."
|
|
193
285
|
},
|
|
194
286
|
{
|
|
195
|
-
"name": "
|
|
196
|
-
"value": "'error'",
|
|
287
|
+
"name": "MULTIPLE",
|
|
197
288
|
"tags": [],
|
|
198
|
-
"docs": ""
|
|
289
|
+
"docs": "Allows multiple selections in the calendar chooser."
|
|
199
290
|
}
|
|
200
291
|
]
|
|
201
292
|
}
|
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
import type { PermissionState } from '@capacitor/core';
|
|
2
2
|
/**
|
|
3
|
-
* Enum
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
3
|
+
* Enum representing the selection style for the calendar chooser.
|
|
4
|
+
* @readonly
|
|
5
|
+
* @enum
|
|
6
|
+
*/
|
|
7
|
+
export declare enum CalendarChooserSelectionStyle {
|
|
8
|
+
/**
|
|
9
|
+
* Allows only a single selection in the calendar chooser.
|
|
10
|
+
*/
|
|
11
|
+
SINGLE = 0,
|
|
12
|
+
/**
|
|
13
|
+
* Allows multiple selections in the calendar chooser.
|
|
14
|
+
*/
|
|
15
|
+
MULTIPLE = 1
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Enum representing the display styles for the calendar chooser.
|
|
7
19
|
* @enum
|
|
8
20
|
*/
|
|
9
|
-
export declare enum
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
21
|
+
export declare enum CalendarChooserDisplayStyle {
|
|
22
|
+
/**
|
|
23
|
+
* Display all calendars available for selection.
|
|
24
|
+
*/
|
|
25
|
+
ALL_CALENDARS = 0,
|
|
26
|
+
/**
|
|
27
|
+
* Display only writable calendars available for selection.
|
|
28
|
+
*/
|
|
29
|
+
WRITABLE_CALENDARS_ONLY = 1
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Represents a calendar object with an ID and title.
|
|
33
|
+
*
|
|
34
|
+
* @interface Calendar
|
|
35
|
+
* @property {string} id - The unique identifier of the calendar.
|
|
36
|
+
* @property {string} title - The title or name of the calendar.
|
|
37
|
+
*/
|
|
38
|
+
export interface Calendar {
|
|
39
|
+
id: string;
|
|
40
|
+
title: string;
|
|
13
41
|
}
|
|
14
42
|
/**
|
|
15
43
|
* Describes the permission status for reading from the calendar.
|
|
@@ -18,6 +46,7 @@ export declare enum CalendarEventActionResult {
|
|
|
18
46
|
*/
|
|
19
47
|
export interface CalendarPermissionStatus {
|
|
20
48
|
readCalendar: PermissionState;
|
|
49
|
+
writeCalendar: PermissionState;
|
|
21
50
|
}
|
|
22
51
|
export interface CapacitorCalendarPlugin {
|
|
23
52
|
/**
|
|
@@ -74,11 +103,11 @@ export interface CapacitorCalendarPlugin {
|
|
|
74
103
|
* On Android, the user has to authorize for read access.
|
|
75
104
|
*
|
|
76
105
|
* @method
|
|
77
|
-
* @returns {Promise<{
|
|
106
|
+
* @returns {Promise<{ eventCreated: boolean }>} – A promise that resolves with the result of the action.
|
|
78
107
|
* @example
|
|
79
108
|
* let result: CalendarEventActionResult;
|
|
80
109
|
* if (capacitor.getPlatform() === 'android') {
|
|
81
|
-
* const readCalendarStatus = this.requestPermission({ alias: 'readCalendar' }).result;
|
|
110
|
+
* const readCalendarStatus = (await this.requestPermission({ alias: 'readCalendar' })).result;
|
|
82
111
|
* if (readCalendarStatus === 'granted') {
|
|
83
112
|
* result = await this.createEventWithPrompt();
|
|
84
113
|
* } else {
|
|
@@ -89,6 +118,26 @@ export interface CapacitorCalendarPlugin {
|
|
|
89
118
|
* }
|
|
90
119
|
*/
|
|
91
120
|
createEventWithPrompt(): Promise<{
|
|
92
|
-
|
|
121
|
+
eventCreated: boolean;
|
|
122
|
+
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Presents a prompt to the user to select calendars. This method is available only on iOS.
|
|
125
|
+
*
|
|
126
|
+
* @method selectCalendarsWithPrompt
|
|
127
|
+
* @param {object} options - Options for customizing the display and selection styles of the calendar chooser.
|
|
128
|
+
* @async
|
|
129
|
+
* @returns { Promise<{ result: Calendar[] }> } A promise that resolves with an array of selected calendars,
|
|
130
|
+
* where each calendar object contains an ID and a title.
|
|
131
|
+
* @example
|
|
132
|
+
* if (capacitor.getPlatform() === 'ios') {
|
|
133
|
+
* const selectedCalendars = await selectCalendarsWithPrompt();
|
|
134
|
+
* console.log(selectedCalendars); // [{ id: '1', title: 'Work Calendar' }]
|
|
135
|
+
* }
|
|
136
|
+
*/
|
|
137
|
+
selectCalendarsWithPrompt(options: {
|
|
138
|
+
displayStyle: CalendarChooserDisplayStyle;
|
|
139
|
+
selectionStyle: CalendarChooserSelectionStyle;
|
|
140
|
+
}): Promise<{
|
|
141
|
+
result: Calendar[];
|
|
93
142
|
}>;
|
|
94
143
|
}
|
package/dist/esm/definitions.js
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Enum
|
|
3
|
-
*
|
|
4
|
-
* for when something went wrong.
|
|
5
|
-
*
|
|
2
|
+
* Enum representing the selection style for the calendar chooser.
|
|
3
|
+
* @readonly
|
|
6
4
|
* @enum
|
|
7
5
|
*/
|
|
8
|
-
export var
|
|
9
|
-
(function (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
export var CalendarChooserSelectionStyle;
|
|
7
|
+
(function (CalendarChooserSelectionStyle) {
|
|
8
|
+
/**
|
|
9
|
+
* Allows only a single selection in the calendar chooser.
|
|
10
|
+
*/
|
|
11
|
+
CalendarChooserSelectionStyle[CalendarChooserSelectionStyle["SINGLE"] = 0] = "SINGLE";
|
|
12
|
+
/**
|
|
13
|
+
* Allows multiple selections in the calendar chooser.
|
|
14
|
+
*/
|
|
15
|
+
CalendarChooserSelectionStyle[CalendarChooserSelectionStyle["MULTIPLE"] = 1] = "MULTIPLE";
|
|
16
|
+
})(CalendarChooserSelectionStyle || (CalendarChooserSelectionStyle = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Enum representing the display styles for the calendar chooser.
|
|
19
|
+
* @enum
|
|
20
|
+
*/
|
|
21
|
+
export var CalendarChooserDisplayStyle;
|
|
22
|
+
(function (CalendarChooserDisplayStyle) {
|
|
23
|
+
/**
|
|
24
|
+
* Display all calendars available for selection.
|
|
25
|
+
*/
|
|
26
|
+
CalendarChooserDisplayStyle[CalendarChooserDisplayStyle["ALL_CALENDARS"] = 0] = "ALL_CALENDARS";
|
|
27
|
+
/**
|
|
28
|
+
* Display only writable calendars available for selection.
|
|
29
|
+
*/
|
|
30
|
+
CalendarChooserDisplayStyle[CalendarChooserDisplayStyle["WRITABLE_CALENDARS_ONLY"] = 1] = "WRITABLE_CALENDARS_ONLY";
|
|
31
|
+
})(CalendarChooserDisplayStyle || (CalendarChooserDisplayStyle = {}));
|
|
14
32
|
//# sourceMappingURL=definitions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAEA
|
|
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<{ 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: 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<CalendarPermissionStatus>} – 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<{ 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: 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<CalendarPermissionStatus>} – 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<{ 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 * @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"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PermissionState, WebPlugin } from '@capacitor/core';
|
|
2
|
-
import { CapacitorCalendarPlugin,
|
|
2
|
+
import { CapacitorCalendarPlugin, CalendarPermissionStatus, Calendar } from './definitions';
|
|
3
3
|
export declare class CapacitorCalendarWeb extends WebPlugin implements CapacitorCalendarPlugin {
|
|
4
4
|
checkPermission(_options: {
|
|
5
5
|
alias: keyof CalendarPermissionStatus;
|
|
@@ -14,6 +14,9 @@ export declare class CapacitorCalendarWeb extends WebPlugin implements Capacitor
|
|
|
14
14
|
}>;
|
|
15
15
|
requestAllPermissions(): Promise<CalendarPermissionStatus>;
|
|
16
16
|
createEventWithPrompt(): Promise<{
|
|
17
|
-
|
|
17
|
+
eventCreated: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
selectCalendarsWithPrompt(): Promise<{
|
|
20
|
+
result: Calendar[];
|
|
18
21
|
}>;
|
|
19
22
|
}
|
package/dist/esm/web.js
CHANGED
|
@@ -15,5 +15,8 @@ export class CapacitorCalendarWeb extends WebPlugin {
|
|
|
15
15
|
createEventWithPrompt() {
|
|
16
16
|
throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);
|
|
17
17
|
}
|
|
18
|
+
selectCalendarsWithPrompt() {
|
|
19
|
+
throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
//# sourceMappingURL=web.js.map
|
package/dist/esm/web.js.map
CHANGED
|
@@ -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;CACJ","sourcesContent":["import {PermissionState, WebPlugin} from '@capacitor/core';\n\nimport
|
|
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"]}
|