Skip to content

Commit 6edb055

Browse files
committed
Make session config optional
1 parent 982acc8 commit 6edb055

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

src/index.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,34 @@ import RNKeyProvider, { type RNKeyProviderOptions } from './e2ee/RNKeyProvider';
2424
import { setupNativeEvents } from './events/EventEmitter';
2525
import { ReadableStream, WritableStream } from 'web-streams-polyfill';
2626

27+
export interface RegisterGlobalsOptions {
28+
/**
29+
* Automatically configure audio session before accessing microphone.
30+
* When enabled, sets the iOS audio category to 'playAndRecord' before getUserMedia.
31+
*
32+
* @default true
33+
* @platform ios
34+
*/
35+
autoConfigureAudioSession?: boolean;
36+
}
37+
2738
/**
2839
* Registers the required globals needed for LiveKit to work.
2940
*
3041
* Must be called before using LiveKit.
42+
*
43+
* @param options Optional configuration for global registration
3144
*/
32-
export function registerGlobals() {
45+
export function registerGlobals(options?: RegisterGlobalsOptions) {
46+
const opts = {
47+
autoConfigureAudioSession: true,
48+
...options,
49+
};
50+
3351
webrtcRegisterGlobals();
34-
iosCategoryEnforce();
52+
if (opts.autoConfigureAudioSession) {
53+
iosCategoryEnforce();
54+
}
3555
livekitRegisterGlobals();
3656
setupURLPolyfill();
3757
fixWebrtcAdapter();
@@ -161,4 +181,5 @@ export type {
161181
LogLevel,
162182
SetLogLevelOptions,
163183
RNKeyProviderOptions,
184+
RegisterGlobalsOptions,
164185
};

0 commit comments

Comments
 (0)