Skip to content

Commit f31891c

Browse files
Merge pull request #218124 from csandjon/csandjon/multiple_tabs
Csandjon/multiple tabs
2 parents 6147985 + b85629b commit f31891c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: Verify if an application is active in multiple tabs of a browser
3+
titleSuffix: An Azure Communication Services how-to guide
4+
description: Learn how to detect if an application is active in multiple tabs of a browser using the Azure Communication Services Calling SDK for JavaScript
5+
author: csandjon
6+
ms.author: csandjon
7+
ms.date: 10/17/2022
8+
ms.topic: how-to
9+
ms.service: azure-communication-services
10+
ms.subservice: calling
11+
ms.custom: template-how-to
12+
---
13+
14+
15+
16+
# How to detect if an application using Azure Communication Services' SDK is active in multiple tabs of a browser
17+
18+
Based on best practices, your application should not connect to calls from multiple browser tabs simultaneously. Handling multiple calls on multiple tabs of a browser on mobile can cause undefined behavior due to resource allocation for microphone and camera on the device.
19+
In order to detect if an application is active in multiple tabs of a browser, a developer can use the method `isCallClientActiveInAnotherTab` and the event `isCallClientActiveInAnotherTabChanged` of a `CallClient` instance.
20+
21+
22+
```javascript
23+
const callClient = new CallClient();
24+
// Check if an application is active in multiple tabs of a browser
25+
const isCallClientActiveInAnotherTab = callClient.feature(SDK.Features.DebugInfo).isCallClientActiveInAnotherTab;
26+
...
27+
// Subscribe to the event to listen for changes
28+
callClient.feature(Features.DebugInfo).on('isCallClientActiveInAnotherTabChanged', () => {
29+
// callback();
30+
});
31+
...
32+
// Unsubscribe from the event to stop listening for changes
33+
callClient.feature(Features.DebugInfo).off('isCallClientActiveInAnotherTabChanged', () => {
34+
// callback();
35+
});
36+
```

articles/communication-services/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ items:
380380
href: how-tos/calling-sdk/events.md
381381
- name: Check if user is running supported browser
382382
href: how-tos/calling-sdk/browser-support.md
383+
- name: Verify if an application is active in multiple tabs of a browser
384+
href: how-tos/calling-sdk/is-sdk-active-in-multiple-tabs.md
383385
- name: Using the UI Library
384386
items:
385387
- name: Setup Localization

0 commit comments

Comments
 (0)