feat(utils): work openFile in simulator (#8495)

* feat: open file in iOS simulator

* feat: added isRealDevice util

* feat: have in mind isRealDevice in utils.openFile

refactor to avoid some circular dependencies

Co-authored-by: Vasil Trifonov <v.trifonov@gmail.com>
This commit is contained in:
tarunama
2020-04-04 01:44:47 +09:00
committed by GitHub
parent 50eb372929
commit bd9828a036
10 changed files with 87 additions and 43 deletions

View File

@ -9,7 +9,7 @@ export * from "./utils-common";
export function openFile(filePath: string): boolean {
try {
const appPath = ios.getCurrentAppPath();
const path = filePath.replace("~", appPath);
let path = ios.isRealDevice() ? filePath.replace("~", appPath) : filePath;
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
controller.delegate = <UIDocumentInteractionControllerDelegate>new ios.UIDocumentInteractionControllerDelegateImpl();
@ -45,3 +45,7 @@ export function openUrl(location: string): boolean {
return false;
}
export function isRealDevice(): boolean {
return ios.isRealDevice();
}