Hi folks, I'm getting the following error Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <MainViewController: 0x157d6850>.
I'm using cordova sdk 6, my app is in Ionic and it used to work until yesterday. In Android still does. I tryed to find a solution but it is always about editing the native code
Thx for the update!
I expect close() to remove the view controller from the hierarchy and with that, destroy the VC and the SDK. Does it not behave like that for you?
our plugin provides four lifecycle methods, open(), close(), show(), hide().
open() is called when you load an Architect World. close() can be used to remove the Wikitude Plugin and show(), hide() can be used to temporarily remove our SDK view from the view hierarchy.
Hi Andreas, thanks a lot for your answer. We solved the problem, the thing is that we called this line again after WikitudePlugin.close(): this.wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin"); But for clarification's sake, the close() function doesn't actually destroys the plugin object is that correct? I think we're still not sure of how to use the function, thanks for your assistance:
A snippet from the iOS Wikitude Plugin code of the `close` function:
__weak WTWikitudePlugin *weakSelf = self;
[self.viewController dismissViewControllerAnimated:YES completion:^
/* nil out the strong reference because it’s not longer needed. ‘show’ and ‘hide’ can handle nil controller and are supposed to be only used during an active presentation of our plugin */
weakSelf.arViewController = nil;
The view controller should be dismissed after `close` is called. You could add some logging here so see if this is reached when our plugin is used within a Ionic application.
Hi, it's me again. We were tinkering and we found out that what causes the error is calling the WikitudePlugin.close() and then recreating the plugin, we do that to update the data that the world uses to create the augmentations. Maybe it is that closing the plugin object doesn't destroy it? and then the app is trying to load the view twice or something like that?
now I found that you can solve this by changing the "presentViewController" to "pushViewController", I tried but I clearly lack the objective-c skills to do it
Hi, actually I found the line in the Wikitude plugin (WTWkitudePlugin.m file) that is causing the error, is this one:
[self.viewController presentViewController:self.arViewController animated:YES completion:nil];
Ok, I think maybe I should have given more details. This error happens when "loadArchitectWorld" os called. That is, whenever the app goes to the Augmented Reality screen (the world), with the camera. I saw that maybe it is a plugin that is conflicting, but it seems there's something with the way the webview of the world is presented. If anybody has any clue, we'd appreciate.