From 1ab2948dd249662fec4f2c38927cdd438f116080 Mon Sep 17 00:00:00 2001 From: Brian Spencer Date: Thu, 28 Mar 2019 17:34:40 -0600 Subject: [PATCH 1/2] Prevent iOS UIDocumentInteractionController from getting garbage collected --- src/share-file.ios.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/share-file.ios.ts b/src/share-file.ios.ts index 8dc3545..9b147ab 100644 --- a/src/share-file.ios.ts +++ b/src/share-file.ios.ts @@ -10,14 +10,17 @@ export class ShareFile { } } + private controller: UIDocumentInteractionController; + + open(args: any): boolean { if (args.path) { try { const appPath = this.getCurrentAppPath(); const path = args.path.replace("~", appPath); - const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path)); - controller.delegate = new UIDocumentInteractionControllerDelegateImpl2(); + this.controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path)); + this.controller.delegate = new UIDocumentInteractionControllerDelegateImpl2(); let rect; if (args.rect) { @@ -26,16 +29,16 @@ export class ShareFile { rect = CGRectMake(0, 0, 0, 0); } - if ( args.options ) { - return controller.presentOptionsMenuFromRectInViewAnimated( + if (args.options) { + return this.controller.presentOptionsMenuFromRectInViewAnimated( rect, - controller.delegate.documentInteractionControllerViewForPreview(controller), + this.controller.delegate.documentInteractionControllerViewForPreview(this.controller), args.animated ? true : false ); } else { - return controller.presentOpenInMenuFromRectInViewAnimated( + return this.controller.presentOpenInMenuFromRectInViewAnimated( rect, - controller.delegate.documentInteractionControllerViewForPreview(controller), + this.controller.delegate.documentInteractionControllerViewForPreview(this.controller), args.animated ? true : false ); } From 63bd5f40f842c24cb25ff647f1b11a68f4583841 Mon Sep 17 00:00:00 2001 From: Brian Spencer Date: Thu, 28 Mar 2019 18:27:13 -0600 Subject: [PATCH 2/2] Remove extra newline --- src/share-file.ios.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/share-file.ios.ts b/src/share-file.ios.ts index 9b147ab..6fc023c 100644 --- a/src/share-file.ios.ts +++ b/src/share-file.ios.ts @@ -12,7 +12,6 @@ export class ShareFile { private controller: UIDocumentInteractionController; - open(args: any): boolean { if (args.path) { try {