From 048cd0ad4fd333bd10b06a734d717dcb618d1a0f Mon Sep 17 00:00:00 2001 From: Aleksi Lahikainen Date: Tue, 8 Sep 2020 13:41:46 +0300 Subject: [PATCH] Return plugin result after the menu is dismissed --- src/ios/FileOpener2.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ios/FileOpener2.m b/src/ios/FileOpener2.m index 2553a8f..3219e07 100644 --- a/src/ios/FileOpener2.m +++ b/src/ios/FileOpener2.m @@ -29,8 +29,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @implementation FileOpener2 @synthesize controller = docController; +CDVPluginResult* pluginResult = nil; +NSString* callbackId = nil; + - (void) open: (CDVInvokedUrlCommand*)command { - NSString *path = [command.arguments objectAtIndex:0]; + callbackId = command.callbackId; + NSString *path = [command.arguments objectAtIndex:0]; NSString *contentType = [command.arguments objectAtIndex:1]; 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]; } - - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; }); } @end @implementation FileOpener2 (UIDocumentInteractionControllerDelegate) + - (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller { + [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId]; + } + - (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller { UIViewController *presentingViewController = self.viewController; if (presentingViewController.view.window != [UIApplication sharedApplication].keyWindow){