From 323808f495c629c8d59b32091ae72257a24308b2 Mon Sep 17 00:00:00 2001 From: Robert Long Date: Mon, 9 Aug 2021 17:36:01 -0700 Subject: [PATCH] Use visibilitychange event on ios to leave call --- src/ConferenceCallManagerHooks.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ConferenceCallManagerHooks.js b/src/ConferenceCallManagerHooks.js index 2febec3..154fa35 100644 --- a/src/ConferenceCallManagerHooks.js +++ b/src/ConferenceCallManagerHooks.js @@ -150,11 +150,18 @@ export function useVideoRoom(manager, roomId, timeout = 5000) { })); function onBeforeUnload(event) { + if ( + event.type === "visibilitychange" && + document.visibilityState === "visible" + ) { + return; + } + manager.leaveCall(); } // iOS doesn't fire beforeunload event, so leave the call when you hide the page. - const unloadEvent = isIOS() ? "pagehide" : "beforeunload"; + const unloadEvent = isIOS() ? "visibilitychange" : "beforeunload"; window.addEventListener(unloadEvent, onBeforeUnload);