Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.x.x
* **Restored ETNotSupportedByPlatform** as it was thrown by `createAttendee()` and `removeAttendee()` methods on iOS.

## 1.0.0
* **Breaking Change - Android Permissions:** Removed default calendar permissions from eventide's `AndroidManifest.xml`. Apps must now declare needed permissions based on their usage:
* `android.permission.READ_CALENDAR` for reading calendars/events
Expand Down
12 changes: 6 additions & 6 deletions example/ios/EventideTests/AttendeeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ final class AttendeeTests: XCTestCase {
XCTFail("Attendee creation should fail on iOS platform")
case .failure(let error):
if let pigeonError = error as? PigeonError {
XCTAssertEqual(pigeonError.code, "INCOMPATIBLE_PLATFORM")
XCTAssertEqual(pigeonError.code, "NOT_SUPPORTED_BY_PLATFORM")
XCTAssertEqual(pigeonError.message, "Platform does not handle this method")
XCTAssertEqual(pigeonError.details as? String, "EventKit API does not support attendee addition")
} else {
XCTFail("Expected PigeonError with INCOMPATIBLE_PLATFORM code")
XCTFail("Expected PigeonError with NOT_SUPPORTED_BY_PLATFORM code")
}
expectation.fulfill()
}
Expand Down Expand Up @@ -91,7 +91,7 @@ final class AttendeeTests: XCTestCase {
XCTFail("Attendee creation should fail due to platform incompatibility")
case .failure(let error):
if let pigeonError = error as? PigeonError {
XCTAssertEqual(pigeonError.code, "INCOMPATIBLE_PLATFORM")
XCTAssertEqual(pigeonError.code, "NOT_SUPPORTED_BY_PLATFORM")
} else {
XCTFail("Expected PigeonError")
}
Expand Down Expand Up @@ -143,11 +143,11 @@ final class AttendeeTests: XCTestCase {
XCTFail("Attendee deletion should fail on iOS platform")
case .failure(let error):
if let pigeonError = error as? PigeonError {
XCTAssertEqual(pigeonError.code, "INCOMPATIBLE_PLATFORM")
XCTAssertEqual(pigeonError.code, "NOT_SUPPORTED_BY_PLATFORM")
XCTAssertEqual(pigeonError.message, "Platform does not handle this method")
XCTAssertEqual(pigeonError.details as? String, "EventKit API does not support attendee deletion")
} else {
XCTFail("Expected PigeonError with INCOMPATIBLE_PLATFORM code")
XCTFail("Expected PigeonError with NOT_SUPPORTED_BY_PLATFORM code")
}
expectation.fulfill()
}
Expand Down Expand Up @@ -175,7 +175,7 @@ final class AttendeeTests: XCTestCase {
XCTFail("Attendee deletion should fail due to platform incompatibility")
case .failure(let error):
if let pigeonError = error as? PigeonError {
XCTAssertEqual(pigeonError.code, "INCOMPATIBLE_PLATFORM")
XCTAssertEqual(pigeonError.code, "NOT_SUPPORTED_BY_PLATFORM")
} else {
XCTFail("Expected PigeonError")
}
Expand Down
8 changes: 6 additions & 2 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objectVersion = 60;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -20,6 +20,7 @@
EA8AABCB2D8D884300A1D69B /* ReminderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA8AABCA2D8D884300A1D69B /* ReminderTests.swift */; };
EA8AABCD2D8D889600A1D69B /* CalendarTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA8AABCC2D8D889600A1D69B /* CalendarTests.swift */; };
EA8AABD12D8D891A00A1D69B /* EventTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA8AABD02D8D891A00A1D69B /* EventTests.swift */; };
EAD7A2722E9E3B5200ED8FE9 /* AttendeeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD7A2712E9E3B5200ED8FE9 /* AttendeeTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -51,6 +52,7 @@
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
Expand All @@ -65,8 +67,8 @@
EA8AABCA2D8D884300A1D69B /* ReminderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReminderTests.swift; sourceTree = "<group>"; };
EA8AABCC2D8D889600A1D69B /* CalendarTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarTests.swift; sourceTree = "<group>"; };
EA8AABD02D8D891A00A1D69B /* EventTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventTests.swift; sourceTree = "<group>"; };
EAD7A2712E9E3B5200ED8FE9 /* AttendeeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttendeeTests.swift; sourceTree = "<group>"; };
EAECB9432D395CA3000FAA80 /* UtilsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilsTests.swift; sourceTree = "<group>"; };
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -146,6 +148,7 @@
isa = PBXGroup;
children = (
EA5CD6D02D8C9A4C004CFD37 /* Mocks */,
EAD7A2712E9E3B5200ED8FE9 /* AttendeeTests.swift */,
EA8AABCA2D8D884300A1D69B /* ReminderTests.swift */,
EA8AABCC2D8D889600A1D69B /* CalendarTests.swift */,
EA8AABD02D8D891A00A1D69B /* EventTests.swift */,
Expand Down Expand Up @@ -323,6 +326,7 @@
EA5CD6CF2D8C9A3B004CFD37 /* MockEasyEventStore.swift in Sources */,
EA5CD6CE2D8C9A3B004CFD37 /* MockPermissionHandler.swift in Sources */,
EA8AABCB2D8D884300A1D69B /* ReminderTests.swift in Sources */,
EAD7A2722E9E3B5200ED8FE9 /* AttendeeTests.swift in Sources */,
EA8AABD12D8D891A00A1D69B /* EventTests.swift in Sources */,
EA8AABCD2D8D889600A1D69B /* CalendarTests.swift in Sources */,
);
Expand Down
4 changes: 2 additions & 2 deletions ios/eventide/Sources/eventide/CalendarImplem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class CalendarImplem: CalendarApi {
/// https://developer.apple.com/documentation/eventkit/ekparticipant#overview
completion(.failure(
PigeonError(
code: "INCOMPATIBLE_PLATFORM",
code: "NOT_SUPPORTED_BY_PLATFORM",
message: "Platform does not handle this method",
details: "EventKit API does not support attendee addition"
)
Expand All @@ -308,7 +308,7 @@ class CalendarImplem: CalendarApi {
/// https://developer.apple.com/documentation/eventkit/ekparticipant#overview
completion(.failure(
PigeonError(
code: "INCOMPATIBLE_PLATFORM",
code: "NOT_SUPPORTED_BY_PLATFORM",
message: "Platform does not handle this method",
details: "EventKit API does not support attendee deletion"
)
Expand Down
1 change: 1 addition & 0 deletions lib/eventide.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export 'src/eventide_exception.dart'
ETNotEditableException,
ETNotFoundException,
ETGenericException,
ETNotSupportedByPlatform,
ETUserCanceledException,
ETPresentationException;
4 changes: 4 additions & 0 deletions lib/src/eventide.dart
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ class Eventide extends EventidePlatform {

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

/// Deletes the attendee with the given [attendee] for the event with the given [eventId].
///
/// Throws a [ETNotSupportedByPlatform] if the method is called on iOS. Make sure you handle it.
///
/// Throws a [ETPermissionException] if the user refuses to grant calendar permissions.
///
/// Throws a [ETNotFoundException] if the event with the given [eventId] is not found.
Expand Down
12 changes: 12 additions & 0 deletions lib/src/eventide_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ final class ETGenericException extends ETException {
}) : super(code: 'GENERIC_ERROR');
}

/// An exception thrown when the requested operation is not supported by the platform.
final class ETNotSupportedByPlatform extends ETException {
ETNotSupportedByPlatform({
required super.message,
super.details,
}) : super(code: 'NOT_SUPPORTED_BY_PLATFORM');
}

/// An exception thrown when the user cancels event creation in the native platform.
final class ETUserCanceledException extends ETException {
ETUserCanceledException({
Expand Down Expand Up @@ -73,6 +81,10 @@ extension PlatformExceptionToETCalendarException on PlatformException {
message: message,
details: details,
),
'NOT_SUPPORTED_BY_PLATFORM' => ETNotSupportedByPlatform(
message: message,
details: details,
),
'USER_CANCELED' => ETUserCanceledException(
message: message,
details: details,
Expand Down
11 changes: 11 additions & 0 deletions test/exceptions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ void main() {
expect(etException.message, 'Not editable');
});

test('Converts PlatformException to ETNotSupportedByPlatform', () {
final platformException = PlatformException(
code: 'NOT_SUPPORTED_BY_PLATFORM',
message: 'Not supported by platform',
);
final etException = platformException.toETException();
expect(etException, isA<ETNotSupportedByPlatform>());
expect(etException.code, 'NOT_SUPPORTED_BY_PLATFORM');
expect(etException.message, 'Not supported by platform');
});

test('Converts PlatformException to ETGenericException', () {
final platformException = PlatformException(
code: 'UNKNOWN_ERROR',
Expand Down