From 8b38b54fb90fa3200fe8a90f1a63ae22adffb564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 31 Jan 2024 12:24:30 +0100 Subject: [PATCH] MOBILE-4266 app: isOnline always returned true on webapp --- src/core/services/network.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/services/network.ts b/src/core/services/network.ts index 397e79f4d..d7206e0b6 100644 --- a/src/core/services/network.ts +++ b/src/core/services/network.ts @@ -159,8 +159,15 @@ export class CoreNetworkService extends Network { return; } - const type = this.connectionType; + // We cannot use navigator.onLine because it has issues in some devices. + // See https://bugs.chromium.org/p/chromium/issues/detail?id=811122 + if (!CorePlatform.isAndroid()) { + this.online = navigator.onLine; + return; + } + + const type = this.connectionType; let online = type !== null && type !== CoreNetworkConnection.NONE && type !== CoreNetworkConnection.UNKNOWN; // Double check we are not online because we cannot rely 100% in Cordova APIs.