From 83e7ffc5bd4aa46a28903ab7a87b402f3bf9536b Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 25 Sep 2017 12:43:07 +0200 Subject: [PATCH] iOS: add event documentHandlerOnDismiss firing --- README.md | 12 ++++++++++++ src/ios/DocumentHandler.m | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index a2b723e..bfd3eef 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ There is a special failure condition on Android, if the system doesn't have any The plugin downloads the document and provides a preview of the document using the Quick Look framework, including the corresponding actions such as copy, print, etc. +## Events (only iOS) + +* documentHandlerOnDismiss - it fires after QuickLook window is closed + ## Example usage handleDocumentWithURL( @@ -38,3 +42,11 @@ including the corresponding actions such as copy, print, etc. }, 'http://www.example.com/path/to/document.pdf' ); + + document.addEventListener( + 'documentHandlerOnDismiss', + function() { + console.log('document handler was closed'); + }, + false, + ); diff --git a/src/ios/DocumentHandler.m b/src/ios/DocumentHandler.m index f2f53a3..a306de0 100644 --- a/src/ios/DocumentHandler.m +++ b/src/ios/DocumentHandler.m @@ -83,6 +83,12 @@ - (void)previewControllerWillDismiss:(QLPreviewController *)controller { } } +- (void)previewControllerDidDismiss:(QLPreviewController *)controller { + NSLog(@"handler dismiss"); + NSString *pluginReadyJSCallbackCommand = [NSString stringWithFormat:@"cordova.fireDocumentEvent('documentHandlerOnDismiss');"]; + [self.commandDelegate evalJs:pluginReadyJSCallbackCommand]; +} + - (id ) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index { return self;