mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
fix: added missing openFile method in ios utils (#7431)
* fix: added missing openFile method in ios utils * chore: deprecate utils.ios.openFile
This commit is contained in:

committed by
GitHub

parent
09d370919f
commit
cb58cab213
@ -89,20 +89,9 @@ export module ios {
|
|||||||
export const MajorVersion = NSString.stringWithString(UIDevice.currentDevice.systemVersion).intValue;
|
export const MajorVersion = NSString.stringWithString(UIDevice.currentDevice.systemVersion).intValue;
|
||||||
|
|
||||||
export function openFile(filePath: string): boolean {
|
export function openFile(filePath: string): boolean {
|
||||||
try {
|
console.log("utils.ios.openFile() is deprecated; use utils.openFile() instead");
|
||||||
const appPath = getCurrentAppPath();
|
|
||||||
const path = filePath.replace("~", appPath);
|
|
||||||
|
|
||||||
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
|
return openFileAtRootModule(filePath);
|
||||||
controller.delegate = new UIDocumentInteractionControllerDelegateImpl();
|
|
||||||
|
|
||||||
return controller.presentPreviewAnimated(true);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCurrentAppPath(): string {
|
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() {
|
export function GC() {
|
||||||
__collect();
|
__collect();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user