@ebarooni/capacitor-calendar 5.0.0 → 5.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 +36 -18
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendar.kt +20 -3
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +43 -2
- package/dist/docs.json +116 -14
- package/dist/esm/definitions.d.ts +90 -7
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +19 -1
- package/dist/esm/web.js +13 -7
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +13 -7
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +13 -7
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorCalendar.swift +62 -8
- package/ios/Plugin/CapacitorCalendarPlugin.m +2 -0
- package/ios/Plugin/CapacitorCalendarPlugin.swift +54 -3
- package/ios/Plugin/CapacitorCalendarPluginError.swift +3 -2
- package/ios/Plugin/EventCreationParameters.swift +1 -0
- package/ios/Plugin/UIColorExtensions.swift +28 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -36,8 +36,17 @@
|
|
|
36
36
|
|
|
37
37
|
## Install
|
|
38
38
|
|
|
39
|
+
### Capacitor 6
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @ebarooni/capacitor-calendar@latest
|
|
43
|
+
npx cap sync
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Capacitor 5
|
|
47
|
+
|
|
39
48
|
```bash
|
|
40
|
-
npm install @ebarooni/capacitor-calendar
|
|
49
|
+
npm install @ebarooni/capacitor-calendar@^5
|
|
41
50
|
npx cap sync
|
|
42
51
|
```
|
|
43
52
|
|
|
@@ -62,28 +71,37 @@ permissions can be found below:
|
|
|
62
71
|
|
|
63
72
|
## 📋 API
|
|
64
73
|
|
|
65
|
-
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
<docgen-index>
|
|
75
|
+
|
|
76
|
+
* [`checkPermission(...)`](#checkpermission)
|
|
77
|
+
* [`checkAllPermissions()`](#checkallpermissions)
|
|
78
|
+
* [`requestPermission(...)`](#requestpermission)
|
|
79
|
+
* [`requestAllPermissions()`](#requestallpermissions)
|
|
80
|
+
* [`createEventWithPrompt(...)`](#createeventwithprompt)
|
|
81
|
+
* [`selectCalendarsWithPrompt(...)`](#selectcalendarswithprompt)
|
|
82
|
+
* [`listCalendars()`](#listcalendars)
|
|
83
|
+
* [`getDefaultCalendar()`](#getdefaultcalendar)
|
|
84
|
+
* [`createEvent(...)`](#createevent)
|
|
85
|
+
* [`getDefaultRemindersList()`](#getdefaultreminderslist)
|
|
86
|
+
* [`getRemindersLists()`](#getreminderslists)
|
|
87
|
+
* [`createReminder(...)`](#createreminder)
|
|
88
|
+
* [`openCalendar(...)`](#opencalendar)
|
|
89
|
+
* [`openReminders()`](#openreminders)
|
|
90
|
+
* [`listEventsInRange(...)`](#listeventsinrange)
|
|
91
|
+
* [`deleteEventsById(...)`](#deleteeventsbyid)
|
|
92
|
+
* [`createCalendar(...)`](#createcalendar)
|
|
93
|
+
* [`deleteCalendar(...)`](#deletecalendar)
|
|
94
|
+
* [Interfaces](#interfaces)
|
|
95
|
+
* [Type Aliases](#type-aliases)
|
|
96
|
+
* [Enums](#enums)
|
|
97
|
+
|
|
98
|
+
</docgen-index>
|
|
81
99
|
|
|
82
100
|
## 📚 Documentation
|
|
83
101
|
|
|
84
102
|
For detailed explanations, usage examples, and additional information:
|
|
85
103
|
|
|
86
|
-
- **documentation.md**: Autogenerated
|
|
104
|
+
- **documentation.md**: Autogenerated docs are available in the [documentation](documentation.md) file.
|
|
87
105
|
- **definitions.ts**: Complete documentation with usage examples is available in the [src/definitions.ts](src/definitions.ts) file.
|
|
88
106
|
|
|
89
107
|
## 💙 Contributions
|
|
@@ -60,7 +60,7 @@ class CapacitorCalendar() {
|
|
|
60
60
|
val title = cursor.getString(nameColumnIndex)
|
|
61
61
|
val calendar =
|
|
62
62
|
JSObject().apply {
|
|
63
|
-
put("id", id)
|
|
63
|
+
put("id", "$id")
|
|
64
64
|
put("title", title)
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -117,11 +117,12 @@ class CapacitorCalendar() {
|
|
|
117
117
|
startDate: Long?,
|
|
118
118
|
endDate: Long?,
|
|
119
119
|
isAllDay: Boolean?,
|
|
120
|
+
alertOffsetInMinutes: Float?,
|
|
120
121
|
): Uri? {
|
|
121
122
|
val startMillis = startDate ?: Calendar.getInstance().timeInMillis
|
|
122
123
|
val endMillis = endDate ?: (startMillis + 3600 * 1000)
|
|
123
124
|
|
|
124
|
-
val
|
|
125
|
+
val eventValues =
|
|
125
126
|
ContentValues().apply {
|
|
126
127
|
put(CalendarContract.Events.DTSTART, startMillis)
|
|
127
128
|
put(CalendarContract.Events.DTEND, endMillis)
|
|
@@ -132,7 +133,23 @@ class CapacitorCalendar() {
|
|
|
132
133
|
isAllDay?.let { put(CalendarContract.Events.ALL_DAY, if (it) 1 else 0) }
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
val eventUri = context.contentResolver.insert(CalendarContract.Events.CONTENT_URI, eventValues)
|
|
137
|
+
|
|
138
|
+
if (alertOffsetInMinutes == null || alertOffsetInMinutes < 0) {
|
|
139
|
+
return eventUri
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
val eventId = eventUri?.lastPathSegment?.toLong() ?: throw IllegalArgumentException("Failed to convert event id to long")
|
|
143
|
+
val alertValues =
|
|
144
|
+
ContentValues().apply {
|
|
145
|
+
put(CalendarContract.Reminders.EVENT_ID, eventId)
|
|
146
|
+
put(CalendarContract.Reminders.MINUTES, alertOffsetInMinutes)
|
|
147
|
+
put(CalendarContract.Reminders.METHOD, CalendarContract.Reminders.METHOD_ALERT)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
context.contentResolver.insert(CalendarContract.Reminders.CONTENT_URI, alertValues)
|
|
151
|
+
|
|
152
|
+
return eventUri
|
|
136
153
|
}
|
|
137
154
|
|
|
138
155
|
@Throws(Exception::class)
|
|
@@ -38,9 +38,26 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
38
38
|
fun createEventWithPrompt(call: PluginCall) {
|
|
39
39
|
try {
|
|
40
40
|
implementation.eventIdsArray = implementation.fetchCalendarEventIDs(context)
|
|
41
|
+
|
|
42
|
+
val title = call.getString("title", "")
|
|
43
|
+
val calendarId = call.getString("calendarId")
|
|
44
|
+
val location = call.getString("location")
|
|
45
|
+
val startDate = call.getLong("startDate")
|
|
46
|
+
val endDate = call.getLong("endDate")
|
|
47
|
+
val isAllDay = call.getBoolean("isAllDay", false)
|
|
48
|
+
|
|
49
|
+
val intent = Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI)
|
|
50
|
+
|
|
51
|
+
intent.putExtra(CalendarContract.Events.TITLE, title)
|
|
52
|
+
calendarId?.let { intent.putExtra(CalendarContract.Events.CALENDAR_ID, it) }
|
|
53
|
+
location?.let { intent.putExtra(CalendarContract.Events.EVENT_LOCATION, it) }
|
|
54
|
+
startDate?.let { intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, it) }
|
|
55
|
+
endDate?.let { intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, it) }
|
|
56
|
+
isAllDay?.let { intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, if (it) 1 else 0) }
|
|
57
|
+
|
|
41
58
|
return startActivityForResult(
|
|
42
59
|
call,
|
|
43
|
-
|
|
60
|
+
intent,
|
|
44
61
|
"openCalendarIntentActivityCallback",
|
|
45
62
|
)
|
|
46
63
|
} catch (error: Exception) {
|
|
@@ -177,8 +194,20 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
177
194
|
val startDate = call.getLong("startDate")
|
|
178
195
|
val endDate = call.getLong("endDate")
|
|
179
196
|
val isAllDay = call.getBoolean("isAllDay", false)
|
|
197
|
+
val alertOffsetInMinutes = call.getFloat("alertOffsetInMinutes")
|
|
198
|
+
|
|
199
|
+
val eventUri =
|
|
200
|
+
implementation.createEvent(
|
|
201
|
+
context,
|
|
202
|
+
title,
|
|
203
|
+
calendarId,
|
|
204
|
+
location,
|
|
205
|
+
startDate,
|
|
206
|
+
endDate,
|
|
207
|
+
isAllDay,
|
|
208
|
+
alertOffsetInMinutes,
|
|
209
|
+
)
|
|
180
210
|
|
|
181
|
-
val eventUri = implementation.createEvent(context, title, calendarId, location, startDate, endDate, isAllDay)
|
|
182
211
|
val id = eventUri?.lastPathSegment ?: throw IllegalArgumentException("Failed to insert event into calendar")
|
|
183
212
|
val ret = JSObject()
|
|
184
213
|
ret.put("result", id)
|
|
@@ -250,4 +279,16 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
250
279
|
return
|
|
251
280
|
}
|
|
252
281
|
}
|
|
282
|
+
|
|
283
|
+
@PluginMethod(returnType = PluginMethod.RETURN_PROMISE)
|
|
284
|
+
fun createCalendar(call: PluginCall) {
|
|
285
|
+
call.unimplemented("[CapacitorCalendar.${::createCalendar.name}] Not implemented on Android")
|
|
286
|
+
return
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
@PluginMethod(returnType = PluginMethod.RETURN_PROMISE)
|
|
290
|
+
fun deleteCalendar(call: PluginCall) {
|
|
291
|
+
call.unimplemented("[CapacitorCalendar.${::deleteCalendar.name}] Not implemented on Android")
|
|
292
|
+
return
|
|
293
|
+
}
|
|
253
294
|
}
|
package/dist/docs.json
CHANGED
|
@@ -141,12 +141,23 @@
|
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
"name": "createEventWithPrompt",
|
|
144
|
-
"signature": "() => Promise<{ result: string[]; }>",
|
|
145
|
-
"parameters": [
|
|
144
|
+
"signature": "(options: { title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; alertOffsetInMinutes?: number; }) => Promise<{ result: string[]; }>",
|
|
145
|
+
"parameters": [
|
|
146
|
+
{
|
|
147
|
+
"name": "options",
|
|
148
|
+
"docs": "- Options for creating the event.",
|
|
149
|
+
"type": "{ title: string; calendarId?: string | undefined; location?: string | undefined; startDate?: number | undefined; endDate?: number | undefined; isAllDay?: boolean | undefined; alertOffsetInMinutes?: number | undefined; }"
|
|
150
|
+
}
|
|
151
|
+
],
|
|
146
152
|
"returns": "Promise<{ result: string[]; }>",
|
|
147
153
|
"tags": [
|
|
148
154
|
{
|
|
149
|
-
"name": "method"
|
|
155
|
+
"name": "method",
|
|
156
|
+
"text": "createEventWithPrompt"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"name": "since",
|
|
160
|
+
"text": "0.1.0"
|
|
150
161
|
},
|
|
151
162
|
{
|
|
152
163
|
"name": "platform",
|
|
@@ -157,16 +168,16 @@
|
|
|
157
168
|
"text": "<h3>Runtime Permissions:</h3>\n<ul>\n <li><strong>Android:</strong> readCalendar</li>\n</ul>"
|
|
158
169
|
},
|
|
159
170
|
{
|
|
160
|
-
"name": "
|
|
161
|
-
"text": "
|
|
171
|
+
"name": "param",
|
|
172
|
+
"text": "options - Options for creating the event."
|
|
162
173
|
},
|
|
163
174
|
{
|
|
164
|
-
"name": "
|
|
165
|
-
"text": "
|
|
175
|
+
"name": "returns",
|
|
176
|
+
"text": "A promise that resolves with an array of the ids of created events."
|
|
166
177
|
},
|
|
167
178
|
{
|
|
168
179
|
"name": "example",
|
|
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}"
|
|
180
|
+
"text": "if (capacitor.getPlatform() === 'android') {\n await this.requestPermission({ alias: 'readCalendar' });\n { result } = result = await this.createEventWithPrompt({\n title: 'Title',\n alertOffsetInMinutes: 5,\n });\n} else {\n { result } = result = await this.createEventWithPrompt({\n title: 'Title',\n alertOffsetInMinutes: 5,\n });\n}"
|
|
170
181
|
}
|
|
171
182
|
],
|
|
172
183
|
"docs": "Creates an event in the calendar by using the native calendar.\nOn iOS opens a native sheet and on Android opens an intent.",
|
|
@@ -189,16 +200,21 @@
|
|
|
189
200
|
"name": "method",
|
|
190
201
|
"text": "selectCalendarsWithPrompt"
|
|
191
202
|
},
|
|
203
|
+
{
|
|
204
|
+
"name": "since",
|
|
205
|
+
"text": "0.2.0"
|
|
206
|
+
},
|
|
192
207
|
{
|
|
193
208
|
"name": "platform",
|
|
194
209
|
"text": "iOS"
|
|
195
210
|
},
|
|
196
211
|
{
|
|
197
|
-
"name": "
|
|
198
|
-
"text": "
|
|
212
|
+
"name": "permissions",
|
|
213
|
+
"text": "<h3>Runtime Permissions:</h3>\n<ul>\n <li><strong>iOS:</strong> writeCalendar</li>\n</ul>"
|
|
199
214
|
},
|
|
200
215
|
{
|
|
201
|
-
"name": "
|
|
216
|
+
"name": "param",
|
|
217
|
+
"text": "options - Options for customizing the display and selection styles of the calendar chooser."
|
|
202
218
|
},
|
|
203
219
|
{
|
|
204
220
|
"name": "returns",
|
|
@@ -280,12 +296,12 @@
|
|
|
280
296
|
},
|
|
281
297
|
{
|
|
282
298
|
"name": "createEvent",
|
|
283
|
-
"signature": "(options: { title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; }) => Promise<{ result: string; }>",
|
|
299
|
+
"signature": "(options: { title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; alertOffsetInMinutes?: number; }) => Promise<{ result: string; }>",
|
|
284
300
|
"parameters": [
|
|
285
301
|
{
|
|
286
302
|
"name": "options",
|
|
287
303
|
"docs": "- Options for creating the event.",
|
|
288
|
-
"type": "{ title: string; calendarId?: string | undefined; location?: string | undefined; startDate?: number | undefined; endDate?: number | undefined; isAllDay?: boolean | undefined; }"
|
|
304
|
+
"type": "{ title: string; calendarId?: string | undefined; location?: string | undefined; startDate?: number | undefined; endDate?: number | undefined; isAllDay?: boolean | undefined; alertOffsetInMinutes?: number | undefined; }"
|
|
289
305
|
}
|
|
290
306
|
],
|
|
291
307
|
"returns": "Promise<{ result: string; }>",
|
|
@@ -312,7 +328,7 @@
|
|
|
312
328
|
},
|
|
313
329
|
{
|
|
314
330
|
"name": "example",
|
|
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
|
|
331
|
+
"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 alertOffsetInMinutes: 5,\n};\nconst { result } = await createEvent(eventOptions);"
|
|
316
332
|
}
|
|
317
333
|
],
|
|
318
334
|
"docs": "Creates an event with the provided options.",
|
|
@@ -580,6 +596,92 @@
|
|
|
580
596
|
"docs": "Deletes events from the calendar given their IDs.",
|
|
581
597
|
"complexTypes": [],
|
|
582
598
|
"slug": "deleteeventsbyid"
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
"name": "createCalendar",
|
|
602
|
+
"signature": "(options: { title: string; color?: string; }) => Promise<{ result: string; }>",
|
|
603
|
+
"parameters": [
|
|
604
|
+
{
|
|
605
|
+
"name": "options",
|
|
606
|
+
"docs": "Options for creating a calendar.",
|
|
607
|
+
"type": "{ title: string; color?: string | undefined; }"
|
|
608
|
+
}
|
|
609
|
+
],
|
|
610
|
+
"returns": "Promise<{ result: string; }>",
|
|
611
|
+
"tags": [
|
|
612
|
+
{
|
|
613
|
+
"name": "method",
|
|
614
|
+
"text": "createCalendar"
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
"name": "since",
|
|
618
|
+
"text": "5.2.0"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
"name": "platform",
|
|
622
|
+
"text": "iOS"
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
"name": "permissions",
|
|
626
|
+
"text": "<h3>Runtime Permissions:</h3>\n<ul>\n <li><strong>iOS:</strong> readCalendar, writeCalendar</li>\n</ul>"
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
"name": "param",
|
|
630
|
+
"text": "options Options for creating a calendar."
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
"name": "returns",
|
|
634
|
+
"text": "The id of the created calendar."
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
"name": "example",
|
|
638
|
+
"text": "{ result } = await CapacitorCalendar.createCalendar({\n title: 'New Calendar',\n color: '#1d00fc',\n });\n console.log(result); // 'CALENDAR_ID'"
|
|
639
|
+
}
|
|
640
|
+
],
|
|
641
|
+
"docs": "Creates a calendar",
|
|
642
|
+
"complexTypes": [],
|
|
643
|
+
"slug": "createcalendar"
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
"name": "deleteCalendar",
|
|
647
|
+
"signature": "(options: { id: string; }) => Promise<void>",
|
|
648
|
+
"parameters": [
|
|
649
|
+
{
|
|
650
|
+
"name": "options",
|
|
651
|
+
"docs": "Options for deleting a calendar.",
|
|
652
|
+
"type": "{ id: string; }"
|
|
653
|
+
}
|
|
654
|
+
],
|
|
655
|
+
"returns": "Promise<void>",
|
|
656
|
+
"tags": [
|
|
657
|
+
{
|
|
658
|
+
"name": "method",
|
|
659
|
+
"text": "deleteCalendar"
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
"name": "since",
|
|
663
|
+
"text": "5.2.0"
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
"name": "platform",
|
|
667
|
+
"text": "iOS"
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
"name": "permissions",
|
|
671
|
+
"text": "<h3>Runtime Permissions:</h3>\n<ul>\n <li><strong>iOS:</strong> readCalendar, writeCalendar</li>\n</ul>"
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
"name": "param",
|
|
675
|
+
"text": "options Options for deleting a calendar."
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
"name": "example",
|
|
679
|
+
"text": "await CapacitorCalendar.deleteCalendar({ id: 'ID_1' });"
|
|
680
|
+
}
|
|
681
|
+
],
|
|
682
|
+
"docs": "Deletes a calendar by id",
|
|
683
|
+
"complexTypes": [],
|
|
684
|
+
"slug": "deletecalendar"
|
|
583
685
|
}
|
|
584
686
|
],
|
|
585
687
|
"properties": []
|
|
@@ -63,33 +63,64 @@ export interface CapacitorCalendarPlugin {
|
|
|
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
65
|
*
|
|
66
|
-
* @method
|
|
66
|
+
* @method createEventWithPrompt
|
|
67
|
+
* @since 0.1.0
|
|
67
68
|
* @platform iOS, Android
|
|
68
69
|
* @permissions
|
|
69
70
|
* <h3>Runtime Permissions:</h3>
|
|
70
71
|
* <ul>
|
|
71
72
|
* <li><strong>Android:</strong> readCalendar</li>
|
|
72
73
|
* </ul>
|
|
74
|
+
* @param {object} options - Options for creating the event.
|
|
75
|
+
* @param {string} options.title - The title of the event.
|
|
76
|
+
* @param {string} options.calendarId - The id of the destination calendar. (Optional)
|
|
77
|
+
* @param {string} [options.location] - The location of the event. (Optional)
|
|
78
|
+
* @param {number} [options.startDate] - The start date and time of the event. (Optional)
|
|
79
|
+
* @param {number} [options.endDate] - The end date and time of the event. (Optional)
|
|
80
|
+
* @param {boolean} [options.isAllDay] - Weather the event is for the entire day or not. (Optional)
|
|
81
|
+
* @param {number} [options.alertOffsetInMinutes] - Ignored on Android. If a number >= 0 is provided,
|
|
82
|
+
* an alert will be set for the event this many minutes *before* the event.
|
|
83
|
+
* Negative values are ignored. (Optional)
|
|
73
84
|
* @returns {Promise<{ result: string[] }>} A promise that resolves with an array of the ids of created events.
|
|
74
|
-
* @throws Error If prompt gets cancelled.
|
|
75
85
|
* @example
|
|
76
86
|
* if (capacitor.getPlatform() === 'android') {
|
|
77
87
|
* await this.requestPermission({ alias: 'readCalendar' });
|
|
78
|
-
* { result } = result = await this.createEventWithPrompt(
|
|
88
|
+
* { result } = result = await this.createEventWithPrompt({
|
|
89
|
+
* title: 'Title',
|
|
90
|
+
* alertOffsetInMinutes: 5,
|
|
91
|
+
* });
|
|
79
92
|
* } else {
|
|
80
|
-
* { result } = await this.createEventWithPrompt(
|
|
93
|
+
* { result } = result = await this.createEventWithPrompt({
|
|
94
|
+
* title: 'Title',
|
|
95
|
+
* alertOffsetInMinutes: 5,
|
|
96
|
+
* });
|
|
81
97
|
* }
|
|
82
98
|
*/
|
|
83
|
-
createEventWithPrompt(
|
|
99
|
+
createEventWithPrompt(options: {
|
|
100
|
+
title: string;
|
|
101
|
+
calendarId?: string;
|
|
102
|
+
location?: string;
|
|
103
|
+
startDate?: number;
|
|
104
|
+
endDate?: number;
|
|
105
|
+
isAllDay?: boolean;
|
|
106
|
+
alertOffsetInMinutes?: number;
|
|
107
|
+
}): Promise<{
|
|
84
108
|
result: string[];
|
|
85
109
|
}>;
|
|
86
110
|
/**
|
|
87
111
|
* Presents a prompt to the user to select calendars. This method is available only on iOS.
|
|
88
112
|
*
|
|
89
113
|
* @method selectCalendarsWithPrompt
|
|
114
|
+
* @since 0.2.0
|
|
90
115
|
* @platform iOS
|
|
116
|
+
* @permissions
|
|
117
|
+
* <h3>Runtime Permissions:</h3>
|
|
118
|
+
* <ul>
|
|
119
|
+
* <li><strong>iOS:</strong> writeCalendar</li>
|
|
120
|
+
* </ul>
|
|
91
121
|
* @param {object} options - Options for customizing the display and selection styles of the calendar chooser.
|
|
92
|
-
* @
|
|
122
|
+
* @param {CalendarChooserDisplayStyle} options.displayStyle - To show all or only writeable calendars.
|
|
123
|
+
* @param {CalendarChooserSelectionStyle} [options.selectionStyle] - To be able to select multiple calendars or only one.
|
|
93
124
|
* @returns { Promise<{ result: Calendar[] }> } A promise that resolves with an array of selected calendars,
|
|
94
125
|
* where each calendar object contains an ID and a title.
|
|
95
126
|
* @example
|
|
@@ -151,6 +182,8 @@ export interface CapacitorCalendarPlugin {
|
|
|
151
182
|
* @param {number} [options.startDate] - The start date and time of the event. (Optional)
|
|
152
183
|
* @param {number} [options.endDate] - The end date and time of the event. (Optional)
|
|
153
184
|
* @param {boolean} [options.isAllDay] - Weather the event is for the entire day or not. (Optional)
|
|
185
|
+
* @param {number} [options.alertOffsetInMinutes] - If a number >= 0 is provided, an alert will be set for the event this many
|
|
186
|
+
* minutes *before* the event. Negative values are ignored. (Optional)
|
|
154
187
|
* @returns {Promise<{ result: string }>} A promise that resolves with the id of the created event.
|
|
155
188
|
* @example
|
|
156
189
|
* const now = Date.now();
|
|
@@ -159,7 +192,8 @@ export interface CapacitorCalendarPlugin {
|
|
|
159
192
|
* location: 'Conference Room A',
|
|
160
193
|
* startDate: now,
|
|
161
194
|
* endDate: now + 2 * 60 * 60 * 1000,
|
|
162
|
-
* isAllDay: false
|
|
195
|
+
* isAllDay: false,
|
|
196
|
+
* alertOffsetInMinutes: 5,
|
|
163
197
|
* };
|
|
164
198
|
* const { result } = await createEvent(eventOptions);
|
|
165
199
|
*/
|
|
@@ -170,6 +204,7 @@ export interface CapacitorCalendarPlugin {
|
|
|
170
204
|
startDate?: number;
|
|
171
205
|
endDate?: number;
|
|
172
206
|
isAllDay?: boolean;
|
|
207
|
+
alertOffsetInMinutes?: number;
|
|
173
208
|
}): Promise<{
|
|
174
209
|
result: string;
|
|
175
210
|
}>;
|
|
@@ -349,4 +384,52 @@ export interface CapacitorCalendarPlugin {
|
|
|
349
384
|
failed: string[];
|
|
350
385
|
};
|
|
351
386
|
}>;
|
|
387
|
+
/**
|
|
388
|
+
* Creates a calendar
|
|
389
|
+
*
|
|
390
|
+
* @method createCalendar
|
|
391
|
+
* @since 5.2.0
|
|
392
|
+
* @platform iOS
|
|
393
|
+
* @permissions
|
|
394
|
+
* <h3>Runtime Permissions:</h3>
|
|
395
|
+
* <ul>
|
|
396
|
+
* <li><strong>iOS:</strong> readCalendar, writeCalendar</li>
|
|
397
|
+
* </ul>
|
|
398
|
+
* @param {object} options Options for creating a calendar.
|
|
399
|
+
* @param {string} options.title The title of the calendar to create.
|
|
400
|
+
* @param {string} options.color The color of the calendar to create.
|
|
401
|
+
* The color should be a HEX string. (Optional)
|
|
402
|
+
* @returns {Promise<{ result: string }>} The id of the created calendar.
|
|
403
|
+
* @example
|
|
404
|
+
* { result } = await CapacitorCalendar.createCalendar({
|
|
405
|
+
* title: 'New Calendar',
|
|
406
|
+
* color: '#1d00fc',
|
|
407
|
+
* });
|
|
408
|
+
* console.log(result); // 'CALENDAR_ID'
|
|
409
|
+
*/
|
|
410
|
+
createCalendar(options: {
|
|
411
|
+
title: string;
|
|
412
|
+
color?: string;
|
|
413
|
+
}): Promise<{
|
|
414
|
+
result: string;
|
|
415
|
+
}>;
|
|
416
|
+
/**
|
|
417
|
+
* Deletes a calendar by id
|
|
418
|
+
*
|
|
419
|
+
* @method deleteCalendar
|
|
420
|
+
* @since 5.2.0
|
|
421
|
+
* @platform iOS
|
|
422
|
+
* @permissions
|
|
423
|
+
* <h3>Runtime Permissions:</h3>
|
|
424
|
+
* <ul>
|
|
425
|
+
* <li><strong>iOS:</strong> readCalendar, writeCalendar</li>
|
|
426
|
+
* </ul>
|
|
427
|
+
* @param {object} options Options for deleting a calendar.
|
|
428
|
+
* @param {string} options.id The id of the calendar to delete.
|
|
429
|
+
* @example
|
|
430
|
+
* await CapacitorCalendar.deleteCalendar({ id: 'ID_1' });
|
|
431
|
+
*/
|
|
432
|
+
deleteCalendar(options: {
|
|
433
|
+
id: string;
|
|
434
|
+
}): Promise<void>;
|
|
352
435
|
}
|
|
@@ -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 *\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:</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 the id of the created event.\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 * @since 0.5.0\n * @platform iOS\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>iOS:</strong> writeReminders</li>\n * </ul>\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<{ result: string }>} A Promise that resolves with the id of the created reminder\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 { result } = await createReminder(reminderOptions);\n * console.log(result); // 'ID_1'\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<{ result: string }>;\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 * @since 0.10.0\n * @platform iOS, Android\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>iOS:</strong> readCalendar</li>\n * <li><strong>Android:</strong> readCalendar</li>\n * </ul>\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 /**\n * Deletes events from the calendar given their IDs.\n *\n * @method deleteEventsById\n * @since 0.11.0\n * @platform iOS, Android\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>iOS:</strong> writeCalendar</li>\n * <li><strong>Android:</strong> writeCalendar</li>\n * </ul>\n * @param {object} options Options for defining event IDs.\n * @param {number} options.ids An array of event IDs to be deleted.\n * @returns {Promise<{ deleted: string[], failed: string[] }>}\n * A promise that resolves to an object with two properties:\n * - deleted: string[] - An array of IDs that were successfully deleted.\n * - failed: string[] - An array of IDs that could not be deleted.\n * @example\n * const idsToDelete = ['ID_1', 'ID_2', 'ID_DOES_NOT_EXIST'];\n * const { result } = await CapacitorCalendar.deleteEventsById(idsToDelete)\n * console.log(result.deleted) // ['ID_1', 'ID_2']\n * console.log(result.failed) // ['ID_DOES_NOT_EXIST']\n */\n deleteEventsById(options: { ids: string[] }): Promise<{ result: { deleted: string[]; failed: string[] } }>;\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 createEventWithPrompt\n * @since 0.1.0\n * @platform iOS, Android\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>Android:</strong> readCalendar</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 * @param {number} [options.alertOffsetInMinutes] - Ignored on Android. If a number >= 0 is provided,\n * an alert will be set for the event this many minutes *before* the event.\n * Negative values are ignored. (Optional)\n * @returns {Promise<{ result: string[] }>} A promise that resolves with an array of the ids of created events.\n * @example\n * if (capacitor.getPlatform() === 'android') {\n * await this.requestPermission({ alias: 'readCalendar' });\n * { result } = result = await this.createEventWithPrompt({\n * title: 'Title',\n * alertOffsetInMinutes: 5,\n * });\n * } else {\n * { result } = result = await this.createEventWithPrompt({\n * title: 'Title',\n * alertOffsetInMinutes: 5,\n * });\n * }\n */\n createEventWithPrompt(options: {\n title: string;\n calendarId?: string;\n location?: string;\n startDate?: number;\n endDate?: number;\n isAllDay?: boolean;\n alertOffsetInMinutes?: number;\n }): 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 * @since 0.2.0\n * @platform iOS\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>iOS:</strong> writeCalendar</li>\n * </ul>\n * @param {object} options - Options for customizing the display and selection styles of the calendar chooser.\n * @param {CalendarChooserDisplayStyle} options.displayStyle - To show all or only writeable calendars.\n * @param {CalendarChooserSelectionStyle} [options.selectionStyle] - To be able to select multiple calendars or only one.\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:</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 * @param {number} [options.alertOffsetInMinutes] - If a number >= 0 is provided, an alert will be set for the event this many\n * minutes *before* the event. Negative values are ignored. (Optional)\n * @returns {Promise<{ result: string }>} A promise that resolves with the id of the created event.\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 * alertOffsetInMinutes: 5,\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 alertOffsetInMinutes?: number;\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 * @since 0.5.0\n * @platform iOS\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>iOS:</strong> writeReminders</li>\n * </ul>\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<{ result: string }>} A Promise that resolves with the id of the created reminder\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 { result } = await createReminder(reminderOptions);\n * console.log(result); // 'ID_1'\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<{ result: string }>;\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 * @since 0.10.0\n * @platform iOS, Android\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>iOS:</strong> readCalendar</li>\n * <li><strong>Android:</strong> readCalendar</li>\n * </ul>\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 /**\n * Deletes events from the calendar given their IDs.\n *\n * @method deleteEventsById\n * @since 0.11.0\n * @platform iOS, Android\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>iOS:</strong> writeCalendar</li>\n * <li><strong>Android:</strong> writeCalendar</li>\n * </ul>\n * @param {object} options Options for defining event IDs.\n * @param {number} options.ids An array of event IDs to be deleted.\n * @returns {Promise<{ deleted: string[], failed: string[] }>}\n * A promise that resolves to an object with two properties:\n * - deleted: string[] - An array of IDs that were successfully deleted.\n * - failed: string[] - An array of IDs that could not be deleted.\n * @example\n * const idsToDelete = ['ID_1', 'ID_2', 'ID_DOES_NOT_EXIST'];\n * const { result } = await CapacitorCalendar.deleteEventsById(idsToDelete)\n * console.log(result.deleted) // ['ID_1', 'ID_2']\n * console.log(result.failed) // ['ID_DOES_NOT_EXIST']\n */\n deleteEventsById(options: { ids: string[] }): Promise<{ result: { deleted: string[]; failed: string[] } }>;\n\n /**\n * Creates a calendar\n *\n * @method createCalendar\n * @since 5.2.0\n * @platform iOS\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>iOS:</strong> readCalendar, writeCalendar</li>\n * </ul>\n * @param {object} options Options for creating a calendar.\n * @param {string} options.title The title of the calendar to create.\n * @param {string} options.color The color of the calendar to create.\n * The color should be a HEX string. (Optional)\n * @returns {Promise<{ result: string }>} The id of the created calendar.\n * @example\n * { result } = await CapacitorCalendar.createCalendar({\n * title: 'New Calendar',\n * color: '#1d00fc',\n * });\n * console.log(result); // 'CALENDAR_ID'\n */\n createCalendar(options: { title: string; color?: string }): Promise<{ result: string }>;\n\n /**\n * Deletes a calendar by id\n *\n * @method deleteCalendar\n * @since 5.2.0\n * @platform iOS\n * @permissions\n * <h3>Runtime Permissions:</h3>\n * <ul>\n * <li><strong>iOS:</strong> readCalendar, writeCalendar</li>\n * </ul>\n * @param {object} options Options for deleting a calendar.\n * @param {string} options.id The id of the calendar to delete.\n * @example\n * await CapacitorCalendar.deleteCalendar({ id: 'ID_1' });\n */\n deleteCalendar(options: { id: string }): Promise<void>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -19,7 +19,15 @@ export declare class CapacitorCalendarWeb extends WebPlugin implements Capacitor
|
|
|
19
19
|
result: PermissionState;
|
|
20
20
|
}>;
|
|
21
21
|
requestAllPermissions(): Promise<PluginPermissionsMap>;
|
|
22
|
-
createEventWithPrompt(
|
|
22
|
+
createEventWithPrompt(_options: {
|
|
23
|
+
title: string;
|
|
24
|
+
calendarId?: string;
|
|
25
|
+
location?: string;
|
|
26
|
+
startDate?: number;
|
|
27
|
+
endDate?: number;
|
|
28
|
+
isAllDay?: boolean;
|
|
29
|
+
alertOffsetInMinutes?: number;
|
|
30
|
+
}): Promise<{
|
|
23
31
|
result: string[];
|
|
24
32
|
}>;
|
|
25
33
|
selectCalendarsWithPrompt(): Promise<{
|
|
@@ -38,6 +46,7 @@ export declare class CapacitorCalendarWeb extends WebPlugin implements Capacitor
|
|
|
38
46
|
startDate?: number;
|
|
39
47
|
endDate?: number;
|
|
40
48
|
isAllDay?: boolean;
|
|
49
|
+
alertOffsetInMinutes?: number;
|
|
41
50
|
}): Promise<{
|
|
42
51
|
result: string;
|
|
43
52
|
}>;
|
|
@@ -80,4 +89,13 @@ export declare class CapacitorCalendarWeb extends WebPlugin implements Capacitor
|
|
|
80
89
|
failed: string[];
|
|
81
90
|
};
|
|
82
91
|
}>;
|
|
92
|
+
createCalendar(_options: {
|
|
93
|
+
title: string;
|
|
94
|
+
color?: string;
|
|
95
|
+
}): Promise<{
|
|
96
|
+
result: string;
|
|
97
|
+
}>;
|
|
98
|
+
deleteCalendar(_options: {
|
|
99
|
+
id: string;
|
|
100
|
+
}): Promise<void>;
|
|
83
101
|
}
|