forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ios.ts
More file actions
51 lines (41 loc) · 1.48 KB
/
Copy pathutils.ios.ts
File metadata and controls
51 lines (41 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { ios } from "./native-helper";
import {
write as traceWrite, categories as traceCategories, messageType as traceMessageType
} from "../trace";
export { ios };
export * from "./utils-common";
export function openFile(filePath: string): boolean {
try {
const appPath = ios.getCurrentAppPath();
let path = ios.isRealDevice() ? filePath.replace("~", appPath) : filePath;
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
controller.delegate = <UIDocumentInteractionControllerDelegate>new ios.UIDocumentInteractionControllerDelegateImpl();
return controller.presentPreviewAnimated(true);
}
catch (e) {
traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error);
}
return false;
}
export function GC() {
__collect();
}
export function releaseNativeObject(object: NSObject) {
__releaseNativeCounterpart(object);
}
export function openUrl(location: string): boolean {
try {
const url = NSURL.URLWithString(location.trim());
if (UIApplication.sharedApplication.canOpenURL(url)) {
return UIApplication.sharedApplication.openURL(url);
}
}
catch (e) {
// We Don't do anything with an error. We just output it
traceWrite("Error in OpenURL", traceCategories.Error, traceMessageType.error);
}
return false;
}
export function isRealDevice(): boolean {
return ios.isRealDevice();
}