From 9884ceb6b34164c770ba5d3e59332b5cfda8522f Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 30 Mar 2022 09:38:55 +0200 Subject: [PATCH] MOBILE-3833 ios: Fix handle iframe links in iOS --- src/core/initializers/inject-ios-scripts.ts | 3 ++- src/core/services/utils/iframe.ts | 19 +++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/core/initializers/inject-ios-scripts.ts b/src/core/initializers/inject-ios-scripts.ts index 64b26993d..cfd717666 100644 --- a/src/core/initializers/inject-ios-scripts.ts +++ b/src/core/initializers/inject-ios-scripts.ts @@ -17,10 +17,11 @@ import { CoreIframeUtils } from '@services/utils/iframe'; import { Platform } from '@singletons'; export default async function(): Promise { + await Platform.ready(); + if (!CoreApp.isIOS() || !('WKUserScript' in window)) { return; } - await Platform.ready(); CoreIframeUtils.injectiOSScripts(window); } diff --git a/src/core/services/utils/iframe.ts b/src/core/services/utils/iframe.ts index 1faf9308e..08745cb44 100644 --- a/src/core/services/utils/iframe.ts +++ b/src/core/services/utils/iframe.ts @@ -446,26 +446,13 @@ export class CoreIframeUtilsProvider { } else { element.setAttribute('src', url); } - } else if (CoreUrlUtils.isLocalFileUrl(url)) { - // It's a local file. - const filename = url.substring(url.lastIndexOf('/') + 1); - - if (!CoreFileHelper.isOpenableInApp({ filename })) { - try { - await CoreFileHelper.showConfirmOpenUnsupportedFile(); - } catch (error) { - return; // Cancelled, stop. - } - } - + } else { try { - await CoreUtils.openFile(url); + // It's an external link or a local file, check if it can be opened in the app. + await CoreWindow.open(url, name); } catch (error) { CoreDomUtils.showErrorModal(error); } - } else { - // It's an external link, check if it can be opened in the app. - await CoreWindow.open(url, name); } }