Skip to content

Commit cb58cab

Browse files
author
Alexander Vakrilov
authored
fix: added missing openFile method in ios utils (#7431)
* fix: added missing openFile method in ios utils * chore: deprecate utils.ios.openFile
1 parent 09d3709 commit cb58cab

1 file changed

Lines changed: 22 additions & 13 deletions

File tree

tns-core-modules/utils/utils.ios.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,9 @@ export module ios {
8989
export const MajorVersion = NSString.stringWithString(UIDevice.currentDevice.systemVersion).intValue;
9090

9191
export function openFile(filePath: string): boolean {
92-
try {
93-
const appPath = getCurrentAppPath();
94-
const path = filePath.replace("~", appPath);
92+
console.log("utils.ios.openFile() is deprecated; use utils.openFile() instead");
9593

96-
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
97-
controller.delegate = new UIDocumentInteractionControllerDelegateImpl();
98-
99-
return controller.presentPreviewAnimated(true);
100-
}
101-
catch (e) {
102-
traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error);
103-
}
104-
105-
return false;
94+
return openFileAtRootModule(filePath);
10695
}
10796

10897
export function getCurrentAppPath(): string {
@@ -146,6 +135,26 @@ export module ios {
146135

147136
}
148137

138+
export function openFile(filePath: string): boolean {
139+
try {
140+
const appPath = ios.getCurrentAppPath();
141+
const path = filePath.replace("~", appPath);
142+
143+
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
144+
controller.delegate = new UIDocumentInteractionControllerDelegateImpl();
145+
146+
return controller.presentPreviewAnimated(true);
147+
}
148+
catch (e) {
149+
traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error);
150+
}
151+
152+
return false;
153+
}
154+
155+
// Need this so that we can use this function inside the ios module (avoid name clashing).
156+
const openFileAtRootModule = openFile;
157+
149158
export function GC() {
150159
__collect();
151160
}

0 commit comments

Comments
 (0)