Skip to content

Commit a36f537

Browse files
Restore ETNotSupportedByPlatform (#76)
* restore ETNotSupportedByPlatform * changelog * fix attendees tests
1 parent 037c2a4 commit a36f537

File tree

8 files changed

+45
-10
lines changed

8 files changed

+45
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.x.x
2+
* **Restored ETNotSupportedByPlatform** as it was thrown by `createAttendee()` and `removeAttendee()` methods on iOS.
3+
14
## 1.0.0
25
* **Breaking Change - Android Permissions:** Removed default calendar permissions from eventide's `AndroidManifest.xml`. Apps must now declare needed permissions based on their usage:
36
* `android.permission.READ_CALENDAR` for reading calendars/events

example/ios/EventideTests/AttendeeTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ final class AttendeeTests: XCTestCase {
5656
XCTFail("Attendee creation should fail on iOS platform")
5757
case .failure(let error):
5858
if let pigeonError = error as? PigeonError {
59-
XCTAssertEqual(pigeonError.code, "INCOMPATIBLE_PLATFORM")
59+
XCTAssertEqual(pigeonError.code, "NOT_SUPPORTED_BY_PLATFORM")
6060
XCTAssertEqual(pigeonError.message, "Platform does not handle this method")
6161
XCTAssertEqual(pigeonError.details as? String, "EventKit API does not support attendee addition")
6262
} else {
63-
XCTFail("Expected PigeonError with INCOMPATIBLE_PLATFORM code")
63+
XCTFail("Expected PigeonError with NOT_SUPPORTED_BY_PLATFORM code")
6464
}
6565
expectation.fulfill()
6666
}
@@ -91,7 +91,7 @@ final class AttendeeTests: XCTestCase {
9191
XCTFail("Attendee creation should fail due to platform incompatibility")
9292
case .failure(let error):
9393
if let pigeonError = error as? PigeonError {
94-
XCTAssertEqual(pigeonError.code, "INCOMPATIBLE_PLATFORM")
94+
XCTAssertEqual(pigeonError.code, "NOT_SUPPORTED_BY_PLATFORM")
9595
} else {
9696
XCTFail("Expected PigeonError")
9797
}
@@ -143,11 +143,11 @@ final class AttendeeTests: XCTestCase {
143143
XCTFail("Attendee deletion should fail on iOS platform")
144144
case .failure(let error):
145145
if let pigeonError = error as? PigeonError {
146-
XCTAssertEqual(pigeonError.code, "INCOMPATIBLE_PLATFORM")
146+
XCTAssertEqual(pigeonError.code, "NOT_SUPPORTED_BY_PLATFORM")
147147
XCTAssertEqual(pigeonError.message, "Platform does not handle this method")
148148
XCTAssertEqual(pigeonError.details as? String, "EventKit API does not support attendee deletion")
149149
} else {
150-
XCTFail("Expected PigeonError with INCOMPATIBLE_PLATFORM code")
150+
XCTFail("Expected PigeonError with NOT_SUPPORTED_BY_PLATFORM code")
151151
}
152152
expectation.fulfill()
153153
}
@@ -175,7 +175,7 @@ final class AttendeeTests: XCTestCase {
175175
XCTFail("Attendee deletion should fail due to platform incompatibility")
176176
case .failure(let error):
177177
if let pigeonError = error as? PigeonError {
178-
XCTAssertEqual(pigeonError.code, "INCOMPATIBLE_PLATFORM")
178+
XCTAssertEqual(pigeonError.code, "NOT_SUPPORTED_BY_PLATFORM")
179179
} else {
180180
XCTFail("Expected PigeonError")
181181
}

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 54;
6+
objectVersion = 60;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -20,6 +20,7 @@
2020
EA8AABCB2D8D884300A1D69B /* ReminderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA8AABCA2D8D884300A1D69B /* ReminderTests.swift */; };
2121
EA8AABCD2D8D889600A1D69B /* CalendarTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA8AABCC2D8D889600A1D69B /* CalendarTests.swift */; };
2222
EA8AABD12D8D891A00A1D69B /* EventTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA8AABD02D8D891A00A1D69B /* EventTests.swift */; };
23+
EAD7A2722E9E3B5200ED8FE9 /* AttendeeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD7A2712E9E3B5200ED8FE9 /* AttendeeTests.swift */; };
2324
/* End PBXBuildFile section */
2425

2526
/* Begin PBXContainerItemProxy section */
@@ -51,6 +52,7 @@
5152
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
5253
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
5354
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
55+
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = "<group>"; };
5456
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
5557
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
5658
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
@@ -65,8 +67,8 @@
6567
EA8AABCA2D8D884300A1D69B /* ReminderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReminderTests.swift; sourceTree = "<group>"; };
6668
EA8AABCC2D8D889600A1D69B /* CalendarTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarTests.swift; sourceTree = "<group>"; };
6769
EA8AABD02D8D891A00A1D69B /* EventTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventTests.swift; sourceTree = "<group>"; };
70+
EAD7A2712E9E3B5200ED8FE9 /* AttendeeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttendeeTests.swift; sourceTree = "<group>"; };
6871
EAECB9432D395CA3000FAA80 /* UtilsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilsTests.swift; sourceTree = "<group>"; };
69-
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = "<group>"; };
7072
/* End PBXFileReference section */
7173

7274
/* Begin PBXFrameworksBuildPhase section */
@@ -146,6 +148,7 @@
146148
isa = PBXGroup;
147149
children = (
148150
EA5CD6D02D8C9A4C004CFD37 /* Mocks */,
151+
EAD7A2712E9E3B5200ED8FE9 /* AttendeeTests.swift */,
149152
EA8AABCA2D8D884300A1D69B /* ReminderTests.swift */,
150153
EA8AABCC2D8D889600A1D69B /* CalendarTests.swift */,
151154
EA8AABD02D8D891A00A1D69B /* EventTests.swift */,
@@ -323,6 +326,7 @@
323326
EA5CD6CF2D8C9A3B004CFD37 /* MockEasyEventStore.swift in Sources */,
324327
EA5CD6CE2D8C9A3B004CFD37 /* MockPermissionHandler.swift in Sources */,
325328
EA8AABCB2D8D884300A1D69B /* ReminderTests.swift in Sources */,
329+
EAD7A2722E9E3B5200ED8FE9 /* AttendeeTests.swift in Sources */,
326330
EA8AABD12D8D891A00A1D69B /* EventTests.swift in Sources */,
327331
EA8AABCD2D8D889600A1D69B /* CalendarTests.swift in Sources */,
328332
);

ios/eventide/Sources/eventide/CalendarImplem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ class CalendarImplem: CalendarApi {
292292
/// https://developer.apple.com/documentation/eventkit/ekparticipant#overview
293293
completion(.failure(
294294
PigeonError(
295-
code: "INCOMPATIBLE_PLATFORM",
295+
code: "NOT_SUPPORTED_BY_PLATFORM",
296296
message: "Platform does not handle this method",
297297
details: "EventKit API does not support attendee addition"
298298
)
@@ -308,7 +308,7 @@ class CalendarImplem: CalendarApi {
308308
/// https://developer.apple.com/documentation/eventkit/ekparticipant#overview
309309
completion(.failure(
310310
PigeonError(
311-
code: "INCOMPATIBLE_PLATFORM",
311+
code: "NOT_SUPPORTED_BY_PLATFORM",
312312
message: "Platform does not handle this method",
313313
details: "EventKit API does not support attendee deletion"
314314
)

lib/eventide.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export 'src/eventide_exception.dart'
1010
ETNotEditableException,
1111
ETNotFoundException,
1212
ETGenericException,
13+
ETNotSupportedByPlatform,
1314
ETUserCanceledException,
1415
ETPresentationException;

lib/src/eventide.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ class Eventide extends EventidePlatform {
319319

320320
/// Creates a new attendee with the given [name], [email], and [type] for the event with the given [eventId].
321321
///
322+
/// Throws a [ETNotSupportedByPlatform] if the method is called on iOS. Make sure you handle it.
323+
///
322324
/// Throws a [ETPermissionException] if the user refuses to grant calendar permissions.
323325
///
324326
/// Throws a [ETNotFoundException] if the event with the given [eventId] is not found.
@@ -347,6 +349,8 @@ class Eventide extends EventidePlatform {
347349

348350
/// Deletes the attendee with the given [attendee] for the event with the given [eventId].
349351
///
352+
/// Throws a [ETNotSupportedByPlatform] if the method is called on iOS. Make sure you handle it.
353+
///
350354
/// Throws a [ETPermissionException] if the user refuses to grant calendar permissions.
351355
///
352356
/// Throws a [ETNotFoundException] if the event with the given [eventId] is not found.

lib/src/eventide_exception.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ final class ETGenericException extends ETException {
4141
}) : super(code: 'GENERIC_ERROR');
4242
}
4343

44+
/// An exception thrown when the requested operation is not supported by the platform.
45+
final class ETNotSupportedByPlatform extends ETException {
46+
ETNotSupportedByPlatform({
47+
required super.message,
48+
super.details,
49+
}) : super(code: 'NOT_SUPPORTED_BY_PLATFORM');
50+
}
51+
4452
/// An exception thrown when the user cancels event creation in the native platform.
4553
final class ETUserCanceledException extends ETException {
4654
ETUserCanceledException({
@@ -73,6 +81,10 @@ extension PlatformExceptionToETCalendarException on PlatformException {
7381
message: message,
7482
details: details,
7583
),
84+
'NOT_SUPPORTED_BY_PLATFORM' => ETNotSupportedByPlatform(
85+
message: message,
86+
details: details,
87+
),
7688
'USER_CANCELED' => ETUserCanceledException(
7789
message: message,
7890
details: details,

test/exceptions_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ void main() {
3939
expect(etException.message, 'Not editable');
4040
});
4141

42+
test('Converts PlatformException to ETNotSupportedByPlatform', () {
43+
final platformException = PlatformException(
44+
code: 'NOT_SUPPORTED_BY_PLATFORM',
45+
message: 'Not supported by platform',
46+
);
47+
final etException = platformException.toETException();
48+
expect(etException, isA<ETNotSupportedByPlatform>());
49+
expect(etException.code, 'NOT_SUPPORTED_BY_PLATFORM');
50+
expect(etException.message, 'Not supported by platform');
51+
});
52+
4253
test('Converts PlatformException to ETGenericException', () {
4354
final platformException = PlatformException(
4455
code: 'UNKNOWN_ERROR',

0 commit comments

Comments
 (0)