diff --git a/package-lock.json b/package-lock.json index 18d46b811..118910478 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8154,6 +8154,11 @@ "resolved": "https://registry.npmjs.org/cordova-plugin-network-information/-/cordova-plugin-network-information-2.0.2.tgz", "integrity": "sha512-NwO3qDBNL/vJxUxBTPNOA1HvkDf9eTeGH8JSZiwy1jq2W2mJKQEDBwqWkaEQS19Yd/MQTiw0cykxg5D7u4J6cQ==" }, + "cordova-plugin-prevent-override": { + "version": "git+https://github.com/moodlemobile/cordova-plugin-prevent-override.git#49507eda3c929e488e58b8402cfc7e1521ebc400", + "from": "git+https://github.com/moodlemobile/cordova-plugin-prevent-override.git", + "dev": true + }, "cordova-plugin-qrscanner": { "version": "git+https://github.com/moodlemobile/cordova-plugin-qrscanner.git#857efee3a7a49104faabd108ff1f00a57d3aca94", "from": "git+https://github.com/moodlemobile/cordova-plugin-qrscanner.git#dist", diff --git a/package.json b/package.json index 69d03672b..f21c7bfd7 100644 --- a/package.json +++ b/package.json @@ -145,6 +145,7 @@ "@typescript-eslint/eslint-plugin": "^4.22.0", "@typescript-eslint/parser": "^4.22.0", "check-es-compat": "^1.1.1", + "cordova-plugin-prevent-override": "git+https://github.com/moodlemobile/cordova-plugin-prevent-override.git", "eslint": "^7.25.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-header": "^3.1.1", @@ -231,7 +232,8 @@ "ANDROID_SUPPORT_VERSION": "28.+" }, "cordova-plugin-globalization": {}, - "cordova-plugin-file-transfer": {} + "cordova-plugin-file-transfer": {}, + "cordova-plugin-prevent-override": {} } }, "optionalDependencies": { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d81f14598..053a354a9 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -167,6 +167,11 @@ export class AppComponent implements OnInit, AfterViewInit { CoreWindow.open(url, name); }; + // Treat URLs that try to override the app. + win.onOverrideUrlLoading = (url: string) => { + CoreWindow.open(url); + }; + CoreEvents.on(CoreEvents.LOGIN, async (data) => { if (data.siteId) { const site = await CoreSites.getSite(data.siteId); diff --git a/src/core/singletons/window.ts b/src/core/singletons/window.ts index f04b6956d..2eee46bf7 100644 --- a/src/core/singletons/window.ts +++ b/src/core/singletons/window.ts @@ -69,8 +69,7 @@ export class CoreWindow { if (name != '_system') { // Check if it can be opened in the app. - treated = false; - await CoreContentLinksHelper.handleLink(url, undefined, true, true); + treated = await CoreContentLinksHelper.handleLink(url, undefined, true, true); } if (!treated) {