@ebarooni/capacitor-calendar 7.3.0 → 7.4.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 +33 -2
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +72 -25
- package/android/src/main/java/dev/barooni/capacitor/calendar/PluginError.kt +8 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/utils/DeclarationCheck.kt +59 -0
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schemas/enums/capacitor-calendar-error-code.d.ts +13 -0
- package/dist/esm/schemas/enums/capacitor-calendar-error-code.js +15 -0
- package/dist/esm/schemas/enums/capacitor-calendar-error-code.js.map +1 -0
- package/dist/plugin.cjs.js +15 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +15 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorCalendarPlugin.swift +68 -22
- package/ios/Plugin/PluginError.swift +13 -0
- package/ios/Plugin/Utils/DeclarationCheck.swift +63 -0
- package/package.json +1 -1
|
@@ -21,6 +21,7 @@ enum PluginError: LocalizedError {
|
|
|
21
21
|
case listNotFound
|
|
22
22
|
case listNotModifiable
|
|
23
23
|
case messageMissing
|
|
24
|
+
case missingDeclaration(String)
|
|
24
25
|
case missingFrequency
|
|
25
26
|
case missingInterval
|
|
26
27
|
case noFieldsToModify
|
|
@@ -76,6 +77,8 @@ enum PluginError: LocalizedError {
|
|
|
76
77
|
return NSLocalizedString("List is not modifiable.", comment: "List not modifiable error")
|
|
77
78
|
case .messageMissing:
|
|
78
79
|
return NSLocalizedString("Message must be provided.", comment: "Message missing error")
|
|
80
|
+
case .missingDeclaration(let key):
|
|
81
|
+
return "Missing Info.plist usage description: \(key)."
|
|
79
82
|
case .missingFrequency:
|
|
80
83
|
return NSLocalizedString("Frequency must be provided.", comment: "Frequency missing error")
|
|
81
84
|
case .missingInterval:
|
|
@@ -102,4 +105,14 @@ enum PluginError: LocalizedError {
|
|
|
102
105
|
return NSLocalizedString("Missing view controller.", comment: "View controller missing error")
|
|
103
106
|
}
|
|
104
107
|
}
|
|
108
|
+
|
|
109
|
+
/// Cap-style reject code when this error provides one; nil for message-only cases.
|
|
110
|
+
var code: String? {
|
|
111
|
+
switch self {
|
|
112
|
+
case .missingDeclaration:
|
|
113
|
+
return "EB-CLDR-0100"
|
|
114
|
+
default:
|
|
115
|
+
return nil
|
|
116
|
+
}
|
|
117
|
+
}
|
|
105
118
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/// Early Info.plist usage-description checks for EB-CLDR-0100 MissingDeclaration.
|
|
4
|
+
/// Callers pass only the access level the method actually uses.
|
|
5
|
+
enum DeclarationCheck {
|
|
6
|
+
/// Throws `PluginError.missingDeclaration` when the Info.plist key for the scope is missing.
|
|
7
|
+
static func ensureUsageDescription(for scope: CalendarPermissionScope) throws {
|
|
8
|
+
switch scope {
|
|
9
|
+
case .writeCalendar:
|
|
10
|
+
try ensureWriteOnlyCalendarUsageDescription()
|
|
11
|
+
case .readCalendar:
|
|
12
|
+
try ensureFullCalendarUsageDescription()
|
|
13
|
+
case .writeReminders, .readReminders:
|
|
14
|
+
try ensureRemindersUsageDescription()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static func ensureWriteOnlyCalendarUsageDescription() throws {
|
|
19
|
+
try ensureUsageDescriptionKey(requiredWriteOnlyCalendarUsageDescriptionKey())
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static func ensureFullCalendarUsageDescription() throws {
|
|
23
|
+
try ensureUsageDescriptionKey(requiredFullCalendarUsageDescriptionKey())
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static func ensureRemindersUsageDescription() throws {
|
|
27
|
+
try ensureUsageDescriptionKey(requiredRemindersUsageDescriptionKey())
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private static func ensureUsageDescriptionKey(_ key: String) throws {
|
|
31
|
+
guard hasUsageDescription(forKey: key) else {
|
|
32
|
+
throw PluginError.missingDeclaration(key)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private static func hasUsageDescription(forKey key: String) -> Bool {
|
|
37
|
+
guard let value = Bundle.main.object(forInfoDictionaryKey: key) as? String else {
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
return !value.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private static func requiredWriteOnlyCalendarUsageDescriptionKey() -> String {
|
|
44
|
+
if #available(iOS 17.0, *) {
|
|
45
|
+
return "NSCalendarsWriteOnlyAccessUsageDescription"
|
|
46
|
+
}
|
|
47
|
+
return "NSCalendarsUsageDescription"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private static func requiredFullCalendarUsageDescriptionKey() -> String {
|
|
51
|
+
if #available(iOS 17.0, *) {
|
|
52
|
+
return "NSCalendarsFullAccessUsageDescription"
|
|
53
|
+
}
|
|
54
|
+
return "NSCalendarsUsageDescription"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private static func requiredRemindersUsageDescriptionKey() -> String {
|
|
58
|
+
if #available(iOS 17.0, *) {
|
|
59
|
+
return "NSRemindersFullAccessUsageDescription"
|
|
60
|
+
}
|
|
61
|
+
return "NSRemindersUsageDescription"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ebarooni/capacitor-calendar",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "A Capacitor plugin for native calendar events on iOS and Android (with reminders on iOS), and .ics event creation on the web.",
|
|
5
5
|
"author": "Ehsan Barooni",
|
|
6
6
|
"license": "MIT",
|