Skip to content

Commit f896d25

Browse files
authored
Hide screenshare button for iOS (#3864)
* Hide screenshare button in Calling and CallWithChat samples when on iOS * Change files * Duplicate change files for beta release * fix imports
1 parent ed5af75 commit f896d25

6 files changed

Lines changed: 56 additions & 14 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "none",
3+
"area": "fix",
4+
"workstream": "Calling and CallWithChat samples",
5+
"comment": "Hide screenshare button in Calling and CallWithChat samples when on iOS",
6+
"packageName": "@azure/communication-react",
7+
"email": "79475487+mgamis-msft@users.noreply.github.com",
8+
"dependentChangeType": "none"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "none",
3+
"area": "fix",
4+
"workstream": "Calling and CallWithChat samples",
5+
"comment": "Hide screenshare button in Calling and CallWithChat samples when on iOS",
6+
"packageName": "@azure/communication-react",
7+
"email": "79475487+mgamis-msft@users.noreply.github.com",
8+
"dependentChangeType": "none"
9+
}

samples/CallWithChat/src/app/utils/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@ export const getBackgroundColor = (avatar: string): { backgroundColor: string }
4444
};
4545
}
4646
};
47+
48+
/**
49+
* Function to detect iOS devices like IPhones, IPads, and IPods
50+
*/
51+
export const isIOS = (): boolean =>
52+
/iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);

samples/CallWithChat/src/app/views/CallScreen.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
CallAndChatLocator,
1010
CallWithChatAdapterState,
1111
CallWithChatComposite,
12-
CallWithChatAdapter
12+
CallWithChatAdapter,
13+
CallWithChatCompositeOptions
1314
} from '@azure/communication-react';
1415
/* @conditional-compile-remove(video-background-effects) */
1516
import { onResolveVideoEffectDependencyLazy, AzureCommunicationCallAdapterOptions } from '@azure/communication-react';
@@ -19,6 +20,7 @@ import { useSwitchableFluentTheme } from '../theming/SwitchableFluentThemeProvid
1920
import { createAutoRefreshingCredential } from '../utils/credential';
2021
import { WEB_APP_TITLE } from '../utils/constants';
2122
import { useIsMobile } from '../utils/useIsMobile';
23+
import { isIOS } from '../utils/utils';
2224

2325
export interface CallScreenProps {
2426
token: string;
@@ -144,6 +146,17 @@ export const CallScreen = (props: CallScreenProps): JSX.Element => {
144146
afterAdapterCreate
145147
);
146148

149+
const shouldDisableScreenShare = isIOS();
150+
151+
const options: CallWithChatCompositeOptions = useMemo(
152+
() => ({
153+
callControls: {
154+
screenShareButton: !shouldDisableScreenShare
155+
}
156+
}),
157+
[shouldDisableScreenShare]
158+
);
159+
147160
// Dispose of the adapter in the window's before unload event.
148161
// This ensures the service knows the user intentionally left the call if the user
149162
// closed the browser tab during an active call.
@@ -169,6 +182,7 @@ export const CallScreen = (props: CallScreenProps): JSX.Element => {
169182
fluentTheme={currentTheme.theme}
170183
rtl={currentRtl}
171184
joinInvitationURL={callInvitationUrl}
185+
options={options}
172186
formFactor={isMobileSession ? 'mobile' : 'desktop'}
173187
/>
174188
);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
/**
5+
* Function to detect iOS devices like IPhones, IPads, and IPods
6+
*/
7+
export const isIOS = (): boolean =>
8+
/iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);

samples/Calling/src/app/views/CallCompositeContainer.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
import { CommonCallAdapter, CallComposite, CallAdapterLocator } from '@azure/communication-react';
5-
/* @conditional-compile-remove(call-readiness) */
6-
import { CallCompositeOptions } from '@azure/communication-react';
4+
import { GroupCallLocator, TeamsMeetingLinkLocator } from '@azure/communication-calling';
5+
import { CallAdapterLocator, CallComposite, CallCompositeOptions, CommonCallAdapter } from '@azure/communication-react';
76
import { Spinner } from '@fluentui/react';
7+
import React, { useEffect, useMemo } from 'react';
88
import { useSwitchableFluentTheme } from '../theming/SwitchableFluentThemeProvider';
99
import { useIsMobile } from '../utils/useIsMobile';
10-
import React, { useEffect } from 'react';
11-
/* @conditional-compile-remove(call-readiness) */
12-
import { useMemo } from 'react';
10+
import { isIOS } from '../utils/utils';
1311
import { CallScreenProps } from './CallScreen';
14-
import { GroupCallLocator, TeamsMeetingLinkLocator } from '@azure/communication-calling';
1512

1613
export type CallCompositeContainerProps = CallScreenProps & { adapter?: CommonCallAdapter };
1714

1815
export const CallCompositeContainer = (props: CallCompositeContainerProps): JSX.Element => {
1916
const { adapter } = props;
2017
const { currentTheme, currentRtl } = useSwitchableFluentTheme();
2118
const isMobileSession = useIsMobile();
19+
const shouldDisableScreenShare = isIOS();
2220

23-
/* @conditional-compile-remove(call-readiness) */
2421
const options: CallCompositeOptions = useMemo(
2522
() => ({
26-
onPermissionsTroubleshootingClick,
27-
onNetworkingTroubleShootingClick,
23+
/* @conditional-compile-remove(call-readiness) */ onPermissionsTroubleshootingClick,
24+
/* @conditional-compile-remove(call-readiness) */ onNetworkingTroubleShootingClick,
2825
callControls: {
29-
legacyControlBarExperience: false
26+
screenShareButton: !shouldDisableScreenShare
3027
}
3128
}),
32-
[]
29+
[shouldDisableScreenShare]
3330
);
3431

3532
// Dispose of the adapter in the window's before unload event.
@@ -58,7 +55,6 @@ export const CallCompositeContainer = (props: CallCompositeContainerProps): JSX.
5855
rtl={currentRtl}
5956
callInvitationUrl={callInvitationUrl}
6057
formFactor={isMobileSession ? 'mobile' : 'desktop'}
61-
/* @conditional-compile-remove(call-readiness) */
6258
options={options}
6359
/>
6460
);

0 commit comments

Comments
 (0)