@ebarooni/capacitor-calendar 0.6.1 → 0.7.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 +28 -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 +61 -783
- package/dist/esm/definitions.d.ts +20 -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 +5 -2
- package/dist/esm/web.js +3 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +61 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +61 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorCalendar.swift +31 -2
- package/ios/Plugin/CapacitorCalendarPlugin.m +1 -0
- package/ios/Plugin/CapacitorCalendarPlugin.swift +20 -2
- package/ios/Plugin/CapacitorCalendarPluginError.swift +1 -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,7 @@ permissions can be found below:
|
|
|
78
79
|
* [`getDefaultRemindersList()`](#getdefaultreminderslist)
|
|
79
80
|
* [`getRemindersLists()`](#getreminderslists)
|
|
80
81
|
* [`createReminder(...)`](#createreminder)
|
|
82
|
+
* [`openCalendar(...)`](#opencalendar)
|
|
81
83
|
* [Interfaces](#interfaces)
|
|
82
84
|
* [Type Aliases](#type-aliases)
|
|
83
85
|
* [Enums](#enums)
|
|
@@ -210,14 +212,14 @@ Retrieves the default calendar set on the device.
|
|
|
210
212
|
### createEvent(...)
|
|
211
213
|
|
|
212
214
|
```typescript
|
|
213
|
-
createEvent(options: { title: string; calendarId?: string; location?: string; startDate?:
|
|
215
|
+
createEvent(options: { title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; }) => Promise<{ eventCreated: boolean; }>
|
|
214
216
|
```
|
|
215
217
|
|
|
216
218
|
Creates an event with the provided options.
|
|
217
219
|
|
|
218
|
-
| Param | Type
|
|
219
|
-
| ------------- |
|
|
220
|
-
| **`options`** | <code>{ title: string; calendarId?: string; location?: string; startDate?:
|
|
220
|
+
| Param | Type | Description |
|
|
221
|
+
| ------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
|
|
222
|
+
| **`options`** | <code>{ title: string; calendarId?: string; location?: string; startDate?: number; endDate?: number; isAllDay?: boolean; }</code> | - Options for creating the event. |
|
|
221
223
|
|
|
222
224
|
**Returns:** <code>Promise<{ eventCreated: boolean; }></code>
|
|
223
225
|
|
|
@@ -267,6 +269,21 @@ Creates a reminder with the provided options.
|
|
|
267
269
|
--------------------
|
|
268
270
|
|
|
269
271
|
|
|
272
|
+
### openCalendar(...)
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
openCalendar(options: { date?: number; }) => Promise<void>
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Opens the calendar app. Since the user leaves your app, use this method with caution.
|
|
279
|
+
|
|
280
|
+
| Param | Type | Description |
|
|
281
|
+
| ------------- | ------------------------------- | ----------------------------------- |
|
|
282
|
+
| **`options`** | <code>{ date?: number; }</code> | - Options for opening the calendar. |
|
|
283
|
+
|
|
284
|
+
--------------------
|
|
285
|
+
|
|
286
|
+
|
|
270
287
|
### Interfaces
|
|
271
288
|
|
|
272
289
|
|
|
@@ -275,7 +292,7 @@ Creates a reminder with the provided options.
|
|
|
275
292
|
|
|
276
293
|
#### Calendar
|
|
277
294
|
|
|
278
|
-
Represents a calendar object
|
|
295
|
+
Represents a calendar object.
|
|
279
296
|
|
|
280
297
|
| Prop | Type |
|
|
281
298
|
| ----------- | ------------------- |
|
|
@@ -283,57 +300,6 @@ Represents a calendar object with an ID and title.
|
|
|
283
300
|
| **`title`** | <code>string</code> |
|
|
284
301
|
|
|
285
302
|
|
|
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
303
|
#### RemindersList
|
|
338
304
|
|
|
339
305
|
|
|
@@ -385,11 +351,11 @@ Enables basic storage and retrieval of dates and times.
|
|
|
385
351
|
|
|
386
352
|
#### ReminderRecurrenceFrequency
|
|
387
353
|
|
|
388
|
-
| Members |
|
|
389
|
-
| ------------- |
|
|
390
|
-
| **`DAILY`** |
|
|
391
|
-
| **`WEEKLY`** |
|
|
392
|
-
| **`MONTHLY`** |
|
|
393
|
-
| **`YEARLY`** |
|
|
354
|
+
| Members | Description |
|
|
355
|
+
| ------------- | --------------------------------------- |
|
|
356
|
+
| **`DAILY`** | The reminder repeats on a daily basis |
|
|
357
|
+
| **`WEEKLY`** | The reminder repeats on a weekly basis |
|
|
358
|
+
| **`MONTHLY`** | The reminder repeats on a monthly basis |
|
|
359
|
+
| **`YEARLY`** | The reminder repeats on a yearly basis |
|
|
394
360
|
|
|
395
361
|
</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
|
}
|