Skip to content

Commit

Permalink
Merge pull request #6 from interrobrian/master
Browse files Browse the repository at this point in the history
Fix unpredictable failure on iOS
  • Loading branch information
baltruschat authored Jul 4, 2019
2 parents 842e306 + 63bd5f4 commit 7e70c69
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/share-file.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ 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) {
Expand All @@ -26,16 +28,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
);
}
Expand Down

0 comments on commit 7e70c69

Please sign in to comment.