From cb58cab213b03137cb28d927b1122d496018d40f Mon Sep 17 00:00:00 2001 From: Alexander Vakrilov Date: Thu, 1 Aug 2019 16:05:32 +0300 Subject: [PATCH] fix: added missing openFile method in ios utils (#7431) * fix: added missing openFile method in ios utils * chore: deprecate utils.ios.openFile --- tns-core-modules/utils/utils.ios.ts | 35 ++++++++++++++++++----------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/tns-core-modules/utils/utils.ios.ts b/tns-core-modules/utils/utils.ios.ts index 303352d51..335497660 100644 --- a/tns-core-modules/utils/utils.ios.ts +++ b/tns-core-modules/utils/utils.ios.ts @@ -89,20 +89,9 @@ export module ios { export const MajorVersion = NSString.stringWithString(UIDevice.currentDevice.systemVersion).intValue; export function openFile(filePath: string): boolean { - try { - const appPath = getCurrentAppPath(); - const path = filePath.replace("~", appPath); + console.log("utils.ios.openFile() is deprecated; use utils.openFile() instead"); - const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path)); - controller.delegate = new UIDocumentInteractionControllerDelegateImpl(); - - return controller.presentPreviewAnimated(true); - } - catch (e) { - traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error); - } - - return false; + return openFileAtRootModule(filePath); } export function getCurrentAppPath(): string { @@ -146,6 +135,26 @@ export module ios { } +export function openFile(filePath: string): boolean { + try { + const appPath = ios.getCurrentAppPath(); + const path = filePath.replace("~", appPath); + + const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path)); + controller.delegate = new UIDocumentInteractionControllerDelegateImpl(); + + return controller.presentPreviewAnimated(true); + } + catch (e) { + traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error); + } + + return false; +} + +// Need this so that we can use this function inside the ios module (avoid name clashing). +const openFileAtRootModule = openFile; + export function GC() { __collect(); }