Return plugin result after the menu is dismissed

This commit is contained in:
Aleksi Lahikainen 2020-09-08 13:41:46 +03:00
parent 7892aa90fd
commit 048cd0ad4f

View File

@ -29,7 +29,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@implementation FileOpener2 @implementation FileOpener2
@synthesize controller = docController; @synthesize controller = docController;
CDVPluginResult* pluginResult = nil;
NSString* callbackId = nil;
- (void) open: (CDVInvokedUrlCommand*)command { - (void) open: (CDVInvokedUrlCommand*)command {
callbackId = command.callbackId;
NSString *path = [command.arguments objectAtIndex:0]; NSString *path = [command.arguments objectAtIndex:0];
NSString *contentType = [command.arguments objectAtIndex:1]; NSString *contentType = [command.arguments objectAtIndex:1];
BOOL showPreview = YES; BOOL showPreview = YES;
@ -117,14 +121,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]; ];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:jsonObj]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:jsonObj];
} }
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}); });
} }
@end @end
@implementation FileOpener2 (UIDocumentInteractionControllerDelegate) @implementation FileOpener2 (UIDocumentInteractionControllerDelegate)
- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller {
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
}
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller { - (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller {
UIViewController *presentingViewController = self.viewController; UIViewController *presentingViewController = self.viewController;
if (presentingViewController.view.window != [UIApplication sharedApplication].keyWindow){ if (presentingViewController.view.window != [UIApplication sharedApplication].keyWindow){