When calling showEventModal with edit set to true my app crashes in iOS.
“Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported’"
My AI says when questioned about this:
On iOS, when edit: true is passed, the plugin's EventsService returns an EKEventEditViewController. This class is a subclass of UINavigationController.
However, the plugin code in DeviceCalendarPlusIosPlugin.swift unconditionally wraps the returned view controller in another UINavigationController. In iOS, passing a UINavigationController as the rootViewController to another UINavigationController constructor is not supported and causes an immediate crash with the error you're seeing.
And proposes a fix in DeviceCalendarPlusIosPlugin.swift:
_// Check if the view controller is already a navigation controller (like EKEventEditViewController)
if let navigationController = viewController as? UINavigationController {
navigationController.modalPresentationStyle = .pageSheet
rootViewController.present(navigationController, animated: true, completion: nil)
} else {
// Wrap EKEventViewController in a navigation controller for proper dismissal and action buttons
let navigationController = UINavigationController(rootViewController: viewController)
navigationController.modalPresentationStyle = .pageSheet
rootViewController.present(navigationController, animated: true, completion: nil)
}_
However, when edit is set to false it open the event as it should, AND there is an Edit button on the top left, which feels kid of strange since you wanted it opened with edit set as false, and if you press the edit button you can edit the event, and when closing and going back to my app the effects have taken place.
So, all in all, a crash bug and a bit of unexpected behaviour. I have not tested this on android, so I think that also needs to be looked into unless done already. I will see if I can check this later.
When calling showEventModal with edit set to true my app crashes in iOS.
“Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported’"
My AI says when questioned about this:
On iOS, when edit: true is passed, the plugin's EventsService returns an EKEventEditViewController. This class is a subclass of UINavigationController.
However, the plugin code in DeviceCalendarPlusIosPlugin.swift unconditionally wraps the returned view controller in another UINavigationController. In iOS, passing a UINavigationController as the rootViewController to another UINavigationController constructor is not supported and causes an immediate crash with the error you're seeing.
And proposes a fix in DeviceCalendarPlusIosPlugin.swift:
However, when edit is set to false it open the event as it should, AND there is an Edit button on the top left, which feels kid of strange since you wanted it opened with edit set as false, and if you press the edit button you can edit the event, and when closing and going back to my app the effects have taken place.
So, all in all, a crash bug and a bit of unexpected behaviour. I have not tested this on android, so I think that also needs to be looked into unless done already. I will see if I can check this later.