MOBILE-3691 android: Prevent URL overriding the app in Android

main
Dani Palou 2021-05-19 10:04:01 +02:00
parent e59d180971
commit 76628503a2
4 changed files with 14 additions and 3 deletions

5
package-lock.json generated
View File

@ -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",

View File

@ -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": {

View File

@ -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);

View File

@ -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) {