@ebarooni/capacitor-calendar 0.6.1 → 0.8.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 +41 -62
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendar.kt +12 -10
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +13 -2
- package/dist/docs.json +87 -783
- package/dist/esm/definitions.d.ts +31 -6
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/schemas/enums/calendar-chooser-display-style.d.ts +2 -1
- package/dist/esm/schemas/enums/calendar-chooser-display-style.js +2 -1
- package/dist/esm/schemas/enums/calendar-chooser-display-style.js.map +1 -1
- package/dist/esm/schemas/enums/calendar-chooser-selection-style.d.ts +2 -1
- package/dist/esm/schemas/enums/calendar-chooser-selection-style.js +2 -1
- package/dist/esm/schemas/enums/calendar-chooser-selection-style.js.map +1 -1
- package/dist/esm/schemas/enums/plugin-permission.d.ts +36 -0
- package/dist/esm/schemas/enums/plugin-permission.js +36 -0
- package/dist/esm/schemas/enums/plugin-permission.js.map +1 -1
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.d.ts +18 -0
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.js +18 -0
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar.d.ts +1 -1
- package/dist/esm/schemas/interfaces/calendar.js.map +1 -1
- package/dist/esm/web.d.ts +6 -2
- package/dist/esm/web.js +6 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +64 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +64 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorCalendar.swift +26 -2
- package/ios/Plugin/CapacitorCalendarPlugin.m +2 -0
- package/ios/Plugin/CapacitorCalendarPlugin.swift +31 -2
- package/ios/Plugin/CapacitorCalendarPluginError.swift +2 -0
- package/ios/Plugin/CapacitorReminders.swift +25 -0
- package/ios/Plugin/EventCreationParameters.swift +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ The video is just for showing the functionality, otherwise the `createEventWithP
|
|
|
51
51
|
- ✅ Get default calendar
|
|
52
52
|
- ✅ Create calendar events without native prompts
|
|
53
53
|
- ✅️ Create reminders (only supported on iOS)
|
|
54
|
+
- ✅ Open calendar app at a specific date
|
|
54
55
|
- ⌛️ Find calendar events
|
|
55
56
|
- ⌛️ Delete calendar events
|
|
56
57
|
|
|
@@ -78,6 +79,8 @@ permissions can be found below:
|
|
|
78
79
|
* [`getDefaultRemindersList()`](#getdefaultreminderslist)
|
|
79
80
|
* [`getRemindersLists()`](#getreminderslists)
|
|
80
81
|
* [`createReminder(...)`](#createreminder)
|
|
82
|
+
* [`openCalendar(...)`](#opencalendar)
|
|
83
|
+
* [`openReminders()`](#openreminders)
|
|
81
84
|
* [Interfaces](#interfaces)
|
|
82
85
|
* [Type Aliases](#type-aliases)
|
|
83
86
|
* [Enums](#enums)
|
|
@@ -210,14 +213,14 @@ Retrieves the default calendar set on the device.
|
|
|
210
213
|
### createEvent(...)
|
|
211
214
|
|
|
212
215
|
```typescript
|
|
213
|
-
createEvent(options: { title: string; calendarId?: string; location?: string; startDate?:
|
|
216
|
+
createEvent(options: { title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; }) => Promise<{ eventCreated: boolean; }>
|
|
214
217
|
```
|
|
215
218
|
|
|
216
219
|
Creates an event with the provided options.
|
|
217
220
|
|
|
218
|
-
| Param | Type
|
|
219
|
-
| ------------- |
|
|
220
|
-
| **`options`** | <code>{ title: string; calendarId?: string; location?: string; startDate?:
|
|
221
|
+
| Param | Type | Description |
|
|
222
|
+
| ------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
|
|
223
|
+
| **`options`** | <code>{ title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; }</code> | - Options for creating the event. |
|
|
221
224
|
|
|
222
225
|
**Returns:** <code>Promise<{ eventCreated: boolean; }></code>
|
|
223
226
|
|
|
@@ -267,6 +270,33 @@ Creates a reminder with the provided options.
|
|
|
267
270
|
--------------------
|
|
268
271
|
|
|
269
272
|
|
|
273
|
+
### openCalendar(...)
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
openCalendar(options: { date?: number; }) => Promise<void>
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Opens the calendar app. Since the user leaves your app, use this method with caution.
|
|
280
|
+
It will open the calendar on today's date if no date is provided.
|
|
281
|
+
|
|
282
|
+
| Param | Type | Description |
|
|
283
|
+
| ------------- | ------------------------------- | ----------------------------------- |
|
|
284
|
+
| **`options`** | <code>{ date?: number; }</code> | - Options for opening the calendar. |
|
|
285
|
+
|
|
286
|
+
--------------------
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
### openReminders()
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
openReminders() => Promise<void>
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Opens the reminders app. Since the user leaves your app, use this method with caution.
|
|
296
|
+
|
|
297
|
+
--------------------
|
|
298
|
+
|
|
299
|
+
|
|
270
300
|
### Interfaces
|
|
271
301
|
|
|
272
302
|
|
|
@@ -275,7 +305,7 @@ Creates a reminder with the provided options.
|
|
|
275
305
|
|
|
276
306
|
#### Calendar
|
|
277
307
|
|
|
278
|
-
Represents a calendar object
|
|
308
|
+
Represents a calendar object.
|
|
279
309
|
|
|
280
310
|
| Prop | Type |
|
|
281
311
|
| ----------- | ------------------- |
|
|
@@ -283,57 +313,6 @@ Represents a calendar object with an ID and title.
|
|
|
283
313
|
| **`title`** | <code>string</code> |
|
|
284
314
|
|
|
285
315
|
|
|
286
|
-
#### Date
|
|
287
|
-
|
|
288
|
-
Enables basic storage and retrieval of dates and times.
|
|
289
|
-
|
|
290
|
-
| Method | Signature | Description |
|
|
291
|
-
| ---------------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
292
|
-
| **toString** | () => string | Returns a string representation of a date. The format of the string depends on the locale. |
|
|
293
|
-
| **toDateString** | () => string | Returns a date as a string value. |
|
|
294
|
-
| **toTimeString** | () => string | Returns a time as a string value. |
|
|
295
|
-
| **toLocaleString** | () => string | Returns a value as a string value appropriate to the host environment's current locale. |
|
|
296
|
-
| **toLocaleDateString** | () => string | Returns a date as a string value appropriate to the host environment's current locale. |
|
|
297
|
-
| **toLocaleTimeString** | () => string | Returns a time as a string value appropriate to the host environment's current locale. |
|
|
298
|
-
| **valueOf** | () => number | Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. |
|
|
299
|
-
| **getTime** | () => number | Gets the time value in milliseconds. |
|
|
300
|
-
| **getFullYear** | () => number | Gets the year, using local time. |
|
|
301
|
-
| **getUTCFullYear** | () => number | Gets the year using Universal Coordinated Time (UTC). |
|
|
302
|
-
| **getMonth** | () => number | Gets the month, using local time. |
|
|
303
|
-
| **getUTCMonth** | () => number | Gets the month of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
304
|
-
| **getDate** | () => number | Gets the day-of-the-month, using local time. |
|
|
305
|
-
| **getUTCDate** | () => number | Gets the day-of-the-month, using Universal Coordinated Time (UTC). |
|
|
306
|
-
| **getDay** | () => number | Gets the day of the week, using local time. |
|
|
307
|
-
| **getUTCDay** | () => number | Gets the day of the week using Universal Coordinated Time (UTC). |
|
|
308
|
-
| **getHours** | () => number | Gets the hours in a date, using local time. |
|
|
309
|
-
| **getUTCHours** | () => number | Gets the hours value in a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
310
|
-
| **getMinutes** | () => number | Gets the minutes of a <a href="#date">Date</a> object, using local time. |
|
|
311
|
-
| **getUTCMinutes** | () => number | Gets the minutes of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
312
|
-
| **getSeconds** | () => number | Gets the seconds of a <a href="#date">Date</a> object, using local time. |
|
|
313
|
-
| **getUTCSeconds** | () => number | Gets the seconds of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
314
|
-
| **getMilliseconds** | () => number | Gets the milliseconds of a <a href="#date">Date</a>, using local time. |
|
|
315
|
-
| **getUTCMilliseconds** | () => number | Gets the milliseconds of a <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
316
|
-
| **getTimezoneOffset** | () => number | Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). |
|
|
317
|
-
| **setTime** | (time: number) => number | Sets the date and time value in the <a href="#date">Date</a> object. |
|
|
318
|
-
| **setMilliseconds** | (ms: number) => number | Sets the milliseconds value in the <a href="#date">Date</a> object using local time. |
|
|
319
|
-
| **setUTCMilliseconds** | (ms: number) => number | Sets the milliseconds value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
320
|
-
| **setSeconds** | (sec: number, ms?: number \| undefined) => number | Sets the seconds value in the <a href="#date">Date</a> object using local time. |
|
|
321
|
-
| **setUTCSeconds** | (sec: number, ms?: number \| undefined) => number | Sets the seconds value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
322
|
-
| **setMinutes** | (min: number, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the minutes value in the <a href="#date">Date</a> object using local time. |
|
|
323
|
-
| **setUTCMinutes** | (min: number, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the minutes value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
324
|
-
| **setHours** | (hours: number, min?: number \| undefined, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the hour value in the <a href="#date">Date</a> object using local time. |
|
|
325
|
-
| **setUTCHours** | (hours: number, min?: number \| undefined, sec?: number \| undefined, ms?: number \| undefined) => number | Sets the hours value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
326
|
-
| **setDate** | (date: number) => number | Sets the numeric day-of-the-month value of the <a href="#date">Date</a> object using local time. |
|
|
327
|
-
| **setUTCDate** | (date: number) => number | Sets the numeric day of the month in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
328
|
-
| **setMonth** | (month: number, date?: number \| undefined) => number | Sets the month value in the <a href="#date">Date</a> object using local time. |
|
|
329
|
-
| **setUTCMonth** | (month: number, date?: number \| undefined) => number | Sets the month value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
330
|
-
| **setFullYear** | (year: number, month?: number \| undefined, date?: number \| undefined) => number | Sets the year of the <a href="#date">Date</a> object using local time. |
|
|
331
|
-
| **setUTCFullYear** | (year: number, month?: number \| undefined, date?: number \| undefined) => number | Sets the year value in the <a href="#date">Date</a> object using Universal Coordinated Time (UTC). |
|
|
332
|
-
| **toUTCString** | () => string | Returns a date converted to a string using Universal Coordinated Time (UTC). |
|
|
333
|
-
| **toISOString** | () => string | Returns a date as a string value in ISO format. |
|
|
334
|
-
| **toJSON** | (key?: any) => string | Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. |
|
|
335
|
-
|
|
336
|
-
|
|
337
316
|
#### RemindersList
|
|
338
317
|
|
|
339
318
|
|
|
@@ -385,11 +364,11 @@ Enables basic storage and retrieval of dates and times.
|
|
|
385
364
|
|
|
386
365
|
#### ReminderRecurrenceFrequency
|
|
387
366
|
|
|
388
|
-
| Members |
|
|
389
|
-
| ------------- |
|
|
390
|
-
| **`DAILY`** |
|
|
391
|
-
| **`WEEKLY`** |
|
|
392
|
-
| **`MONTHLY`** |
|
|
393
|
-
| **`YEARLY`** |
|
|
367
|
+
| Members | Description |
|
|
368
|
+
| ------------- | --------------------------------------- |
|
|
369
|
+
| **`DAILY`** | The reminder repeats on a daily basis |
|
|
370
|
+
| **`WEEKLY`** | The reminder repeats on a weekly basis |
|
|
371
|
+
| **`MONTHLY`** | The reminder repeats on a monthly basis |
|
|
372
|
+
| **`YEARLY`** | The reminder repeats on a yearly basis |
|
|
394
373
|
|
|
395
374
|
</docgen-api>
|
|
@@ -3,13 +3,12 @@ package dev.barooni.capacitor.calendar
|
|
|
3
3
|
import android.content.ContentResolver
|
|
4
4
|
import android.content.ContentValues
|
|
5
5
|
import android.content.Context
|
|
6
|
+
import android.content.Intent
|
|
6
7
|
import android.net.Uri
|
|
7
8
|
import android.provider.CalendarContract
|
|
8
9
|
import com.getcapacitor.JSArray
|
|
9
10
|
import com.getcapacitor.JSObject
|
|
10
|
-
import java.text.SimpleDateFormat
|
|
11
11
|
import java.util.Calendar
|
|
12
|
-
import java.util.Locale
|
|
13
12
|
import java.util.TimeZone
|
|
14
13
|
|
|
15
14
|
class CapacitorCalendar() {
|
|
@@ -105,16 +104,12 @@ class CapacitorCalendar() {
|
|
|
105
104
|
title: String,
|
|
106
105
|
calendarId: String?,
|
|
107
106
|
location: String?,
|
|
108
|
-
startDate:
|
|
109
|
-
endDate:
|
|
107
|
+
startDate: Long?,
|
|
108
|
+
endDate: Long?,
|
|
110
109
|
isAllDay: Boolean?,
|
|
111
110
|
): Uri? {
|
|
112
|
-
val
|
|
113
|
-
|
|
114
|
-
timeZone = TimeZone.getTimeZone("UTC")
|
|
115
|
-
}
|
|
116
|
-
val startMillis = startDate?.let { isoFormatter.parse(it)?.time } ?: Calendar.getInstance().timeInMillis
|
|
117
|
-
val endMillis = endDate?.let { isoFormatter.parse(it)?.time } ?: (startMillis + 3600 * 1000)
|
|
111
|
+
val startMillis = startDate ?: Calendar.getInstance().timeInMillis
|
|
112
|
+
val endMillis = endDate ?: (startMillis + 3600 * 1000)
|
|
118
113
|
|
|
119
114
|
val values =
|
|
120
115
|
ContentValues().apply {
|
|
@@ -129,4 +124,11 @@ class CapacitorCalendar() {
|
|
|
129
124
|
|
|
130
125
|
return context.contentResolver.insert(CalendarContract.Events.CONTENT_URI, values)
|
|
131
126
|
}
|
|
127
|
+
|
|
128
|
+
@Throws(Exception::class)
|
|
129
|
+
fun openCalendar(timestamp: Long): Intent {
|
|
130
|
+
return Intent(Intent.ACTION_VIEW).apply {
|
|
131
|
+
data = Uri.parse("content://com.android.calendar/time/$timestamp")
|
|
132
|
+
}
|
|
133
|
+
}
|
|
132
134
|
}
|
|
@@ -178,8 +178,8 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
178
178
|
?: throw Exception("[CapacitorCalendar.${::createEvent.name}] A title for the event was not provided")
|
|
179
179
|
val calendarId = call.getString("calendarId")
|
|
180
180
|
val location = call.getString("location")
|
|
181
|
-
val startDate = call.
|
|
182
|
-
val endDate = call.
|
|
181
|
+
val startDate = call.getLong("startDate")
|
|
182
|
+
val endDate = call.getLong("endDate")
|
|
183
183
|
val isAllDay = call.getBoolean("isAllDay", false)
|
|
184
184
|
|
|
185
185
|
val eventUri = implementation.createEvent(context, title, calendarId, location, startDate, endDate, isAllDay)
|
|
@@ -209,4 +209,15 @@ class CapacitorCalendarPlugin : Plugin() {
|
|
|
209
209
|
call.unimplemented("[CapacitorCalendar.${::createReminder.name}] Not implemented on Android")
|
|
210
210
|
return
|
|
211
211
|
}
|
|
212
|
+
|
|
213
|
+
@PluginMethod(returnType = PluginMethod.RETURN_NONE)
|
|
214
|
+
fun openCalendar(call: PluginCall) {
|
|
215
|
+
val timestamp = call.getLong("date") ?: System.currentTimeMillis()
|
|
216
|
+
try {
|
|
217
|
+
return activity.startActivity(implementation.openCalendar(timestamp))
|
|
218
|
+
} catch (error: Exception) {
|
|
219
|
+
call.reject("", "[CapacitorCalendar.${::openCalendar.name}] Unable to open calendar")
|
|
220
|
+
return
|
|
221
|
+
}
|
|
222
|
+
}
|
|
212
223
|
}
|