damp-kite-83575
11/03/2025, 8:25 AMtall-airline-16756
11/03/2025, 8:25 AMtall-airline-16756
11/03/2025, 8:26 AMaudio and voip UIBackgroundModes in your Xcode project by going to Signing & Capabilities → Add Capability → Background Modes.
• If you’re using Flutter, just add the following to your `Info.plist`:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
• For the best experience, consider integrating CallKit and managing audio session activation and deactivation properly.
For Android:
• Set up a foreground service and don’t forget to declare the necessary permissions in your AndroidManifest.xml, like android.permission.FOREGROUND_SERVICE.
• Also, declare the service with the right foreground service types such as camera, microphone, or mediaPlayback.
Testing and configuring your audio sessions carefully will really help keep your calls connected even when switching apps. If you’d like, I’m here to walk you through any part of this or provide more details. Just let me know!
Sources: docs/index.html | README.md | How We Built a Globally Distributed WebRTC Mesh Networkdamp-kite-83575
11/03/2025, 8:31 AMtall-airline-16756
11/03/2025, 8:33 AMprovider:didActivate: and provider:didDeactivate: events to keep the audio session stable.
• Try disabling automatic audio session configuration so you can manage the audio engine availability yourself.
• Don’t forget to enable background modes like Audio, AirPlay, and Picture in Picture and Voice over IP in your Xcode project to keep things running smoothly.
For Android:
• It’s important to manage audio focus properly using MODE_IN_COMMUNICATION to support voice calls effectively.
• Consider implementing a foreground service with the right permissions and service types, such as microphone and mediaPlayback, to help maintain the connection.
• Also, handling audio interruptions and routing carefully can make a big difference in preventing disconnections.
Following these suggestions should help keep microphone access stable and reduce disconnections when switching between apps. If you’d like, I’m here to guide you through any part of this process—just let me know!
Sources: README.md | Flutter quickstart | LiveKit docs | callkit/README.md | Mobile SDKs (Flutter, iOS, Android) | livekit/livekit_composite | DeepWiki | docs/index.htmldamp-kite-83575
11/03/2025, 8:34 AMtall-airline-16756
11/03/2025, 8:34 AMAudio, AirPlay, and Picture in Picture
◦ Voice over IP
1. Next, integrate CallKit into your app:
◦ Disable automatic audio session configuration by adding this code:
AudioManager.shared.audioSession.isAutomaticConfigurationEnabled = false
◦ Manually control the audio engine availability with:
try AudioManager.shared.setEngineAvailability(.none)
◦ Implement the provider:didActivate: and provider:didDeactivate: methods in your CXProviderDelegate to manage audio sessions smoothly:
func provider(_: CXProvider, didActivate session: AVAudioSession) {
try session.setCategory(.playAndRecord, mode: .voiceChat, options: [.mixWithOthers])
try AudioManager.shared.setEngineAvailability(.default)
}
func provider(_: CXProvider, didDeactivate _: AVAudioSession) {
try AudioManager.shared.setEngineAvailability(.none)
}
1. Finally, test your app to make sure the audio session stays active even when switching to other apps.
For Android:
1. Open your AndroidManifest.xml file and add these permissions:
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
2. Declare a foreground service in your AndroidManifest.xml with the right service types:
<service android:name="your.foreground.service"
android:foregroundservicetype="microphone|mediaPlayback"/>
3. Set up audio focus management in your app:
◦ Use MODE_IN_COMMUNICATION for voice call audio mode.
◦ Handle audio interruptions and routing carefully to keep the connection stable.
1. Don’t forget to test your app to ensure the connection stays solid when switching between apps.
Take your time with these steps, and please feel free to reach out if you want me to clarify anything or if you need a hand with any part of the setup. I’m here to support you!damp-kite-83575
11/03/2025, 8:36 AMtall-airline-16756
11/03/2025, 8:38 AM// This is the default setup - no extra configuration needed
val room = LiveKit.create(applicationContext)
// AudioSwitchHandler is used automatically with default settings
3. Custom Audio Focus Configuration:
val audioOptions = AudioOptions(
audioHandler = AudioFocusHandler(context),
audioOutputType = AudioType.CallAudioType() // Perfect for voice communication
)
val overrides = LiveKitOverrides(
audioOptions = audioOptions
)
val room = LiveKit.create(applicationContext, overrides)
4. Advanced AudioSwitchHandler Configuration:
val audioSwitchHandler = AudioSwitchHandler(context).apply {
manageAudioFocus = true
focusMode = AudioManager.AUDIOFOCUS_GAIN
audioMode = AudioManager.MODE_IN_COMMUNICATION
audioStreamType = AudioManager.STREAM_VOICE_CALL
audioAttributeUsageType = AudioAttributes.USAGE_VOICE_COMMUNICATION
audioAttributeContentType = AudioAttributes.CONTENT_TYPE_SPEECH
onAudioFocusChangeListener = AudioManager.OnAudioFocusChangeListener { focusChange ->
when (focusChange) {
AudioManager.AUDIOFOCUS_GAIN -> {
// Resume audio processing
}
AudioManager.AUDIOFOCUS_LOSS -> {
// Pause audio processing
}
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
// Temporarily pause audio
}
}
}
}
val audioOptions = AudioOptions(
audioHandler = audioSwitchHandler,
audioOutputType = AudioType.CallAudioType()
)
val overrides = LiveKitOverrides(audioOptions = audioOptions)
val room = LiveKit.create(applicationContext, overrides)
5. Handle Audio Focus Changes:
audioSwitchHandler.onAudioFocusChangeListener = AudioManager.OnAudioFocusChangeListener { focusChange ->
when (focusChange) {
AudioManager.AUDIOFOCUS_GAIN -> {
room.localParticipant.setMicrophoneEnabled(true)
}
AudioManager.AUDIOFOCUS_LOSS -> {
room.localParticipant.setMicrophoneEnabled(false)
}
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
room.localParticipant.setMicrophoneEnabled(false)
}
}
}
Feel free to follow these steps, and if anything feels unclear or if you’d like me to walk you through any part in more detail, just let me know. I’m here to make sure everything works smoothly for you!
Sources: README.md | README.mddamp-kite-83575
11/03/2025, 9:21 AMtall-airline-16756
11/03/2025, 9:21 AMdefaultOutput in AudioConfiguration to set the fallback output to either speaker or earpiece. By default, it’s set to speaker.
• If you’d like the speaker to be preferred over the earpiece during automatic configuration, just set isSpeakerOutputPreferred to true.
2. Manual Audio Output Selection:
• Try using the getAudioOutputs() method to see the available options (default and force_speaker).
• Then, you can call setAudioOutput() to switch between these options whenever you need.
3. Show Audio Route Picker:
• The showAudioRoutePicker() method lets you display iOS’s native route picker, so users can easily choose audio output devices like Bluetooth headsets, AirPlay speakers, or wired headphones.
4. Advanced Configuration:
• If you want to dive a bit deeper, you can use setAppleAudioConfiguration() to customize the AVAudioSession settings, such as enabling .allowBluetooth, .defaultToSpeaker, or .mixWithOthers.
If you’d like, I’m here to guide you through implementing any of these options—just let me know how I can assist!
Sources: docs/classes/AudioSession.html | Sources/LiveKit/Audio/Manager/AudioManager.swift | lib/src/hardware/hardware.dartdamp-kite-83575
11/03/2025, 9:38 AMtall-airline-16756
11/03/2025, 9:40 AMconst options = {
ios: {
appName: 'LiveKitReactNative',
includeCallsInRecents: false,
audioSession: {
categoryOptions:
AudioSessionCategoryOption.allowAirPlay +
AudioSessionCategoryOption.allowBluetooth +
AudioSessionCategoryOption.allowBluetoothA2DP +
AudioSessionCategoryOption.defaultToSpeaker,
mode: AudioSessionMode.voiceChat,
},
},
};
RNCallKeep.setSettings(options);
2. Handle CallKit Audio Session Events:
RNCallKeep.addEventListener('didActivateAudioSession', () => {
RTCAudioSession.audioSessionDidActivate();
});
RNCallKeep.addEventListener('didDeactivateAudioSession', () => {
RTCAudioSession.audioSessionDidDeactivate();
});
3. Configure LiveKit Audio:
await AudioSession.configureAudio({
ios: {
defaultOutput: 'speaker',
audioCategory: 'playAndRecord',
audioCategoryOptions: [
'allowAirPlay',
'allowBluetooth',
'allowBluetoothA2DP',
'defaultToSpeaker'
],
audioMode: 'voiceChat',
}
});
4. Manage Call State:
export async function startCallService() {
let handle = '1234567';
let contactIdentifier = 'Caller Contact';
RNCallKeep.startCall(uuid, handle, contactIdentifier, 'number', true);
RNCallKeep.reportConnectingOutgoingCallWithUUID(uuid);
setTimeout(() => {
RNCallKeep.reportConnectedOutgoingCallWithUUID(uuid);
}, 100);
}
export async function stopCallService() {
RNCallKeep.endCall(uuid);
RNCallKeep.reportEndCallWithUUID(uuid, CK_CONSTANTS.END_CALL_REASONS.REMOTE_ENDED);
}
5. Troubleshooting:
• Make sure background modes (audio and voip) are enabled in your iOS project settings.
• It’s important to handle CallKit events before connecting to the LiveKit room to avoid any issues.
• If you want to give users control over audio output, consider using showAudioRoutePicker().
If you run into any challenges or want me to walk you through a particular step, please don’t hesitate to ask. I’m here to help you get this working smoothly!
Sources: src/index.tsx | README.md | README.mddamp-kite-83575
11/03/2025, 9:55 AMtall-airline-16756
11/03/2025, 9:56 AMAudio, AirPlay, and Picture in Picture and Voice over IP.
• Also, double-check that your Info.plist includes this:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>voip</string>
</array>
2. Integrate CallKit:
• Using react-native-callkeep is a great way to manage CallKit events.
• Don’t forget to handle audio session activation and deactivation like this:
RNCallKeep.addEventListener('didActivateAudioSession', () => {
RTCAudioSession.audioSessionDidActivate();
});
RNCallKeep.addEventListener('didDeactivateAudioSession', () => {
RTCAudioSession.audioSessionDidDeactivate();
});
3. Synchronize Audio Session with CallKit:
• It’s helpful to disable automatic audio session configuration in LiveKit by setting:
• Then, set the audio session category and mode when activating:
func provider(_: CXProvider, didActivate session: AVAudioSession) {
try session.setCategory(.playAndRecord, mode: .voiceChat, options: [.mixWithOthers])
try AudioManager.shared.setEngineAvailability(.default)
}
• And when deactivating, make sure to revoke engine availability:
func provider(_: CXProvider, didDeactivate _: AVAudioSession) {
try AudioManager.shared.setEngineAvailability(.none)
}
4. Test and Troubleshoot:
• Check that no other plugins or background services are conflicting with your audio functionality.
• Try testing your app in real-world situations, like switching to other apps or locking the screen, to see how it behaves.
Following these steps should really help keep your voice communication uninterrupted. If you hit any bumps or want to dive deeper into any part of the setup, just let me know—I’m here to help!
Sources: Camera & microphone | LiveKit Docs | example/src/callservice/CallService.ios.ts | callkit/README.md | README.mddamp-kite-83575
11/03/2025, 10:54 AMtall-airline-16756
11/03/2025, 10:54 AMAudio and VoIP in the UIBackgroundModes section of your Info.plist. This allows your app to keep running during calls in the background:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>voip</string>
</array>
2. CallKit Integration:
• If you’re using CallKit to handle incoming calls, you’ll need the com.apple.developer.pushkit.unrestricted-voip entitlement. This lets PushKit notifications trigger the CallKit interface smoothly.
3. Background Camera Access (iOS 18+):
• For multitasking with the camera, don’t forget to enable the voip background mode and set enableMultitaskingCameraAccess in your app’s configuration.
These steps help make sure your voice calls stay uninterrupted and that you can take full advantage of the advanced features. If you have any questions or want help with a specific part of your setup, just let me know—I’m here to help!
Sources: Swift quickstart | LiveKit docs | README.md | minimal-pip/minimal-pip/Info.plist | VoiceAgent/Info.plist | Documentation/iOSInstallation.mddamp-kite-83575
11/03/2025, 10:57 AMtall-airline-16756
11/03/2025, 10:57 AMdidDeactivateAudioSession event from RNCallKeep won’t disconnect your LiveKit connection as long as it’s handled properly. It’s really helpful to call RTCAudioSession.audioSessionDidDeactivate() within this event to make sure your WebRTC connection stays smooth and the audio session state is managed correctly.
This step lets the WebRTC backend know that the audio session has been deactivated, so LiveKit can take care of audio routing and background execution just right. You can safely add this to your configuration:
RNCallKeep.addEventListener('didDeactivateAudioSession', () => {
console.log("session is deactivated");
RTCAudioSession.audioSessionDidDeactivate();
});
If you have any questions or want me to walk you through this setup, please don’t hesitate to ask. I’m here to help!
Sources: docs/index.html | Documentation/iOSInstallation.mddamp-kite-83575
11/03/2025, 11:10 AMtall-airline-16756
11/03/2025, 11:12 AMdidActivateAudioSession and didDeactivateAudioSession events correctly. This helps keep everything in sync:
RNCallKeep.addEventListener('didActivateAudioSession', () => {
console.log("session is activated");
RTCAudioSession.audioSessionDidActivate();
});
RNCallKeep.addEventListener('didDeactivateAudioSession', () => {
console.log("session is deactivated");
RTCAudioSession.audioSessionDidDeactivate();
});
2. Check that your CallKit configuration includes the right audio session settings to support smooth audio handling:
const options = {
ios: {
appName: 'LiveKitReactNative',
includeCallsInRecents: false,
audioSession: {
categoryOptions:
AudioSessionCategoryOption.allowAirPlay |
AudioSessionCategoryOption.allowBluetooth |
AudioSessionCategoryOption.allowBluetoothA2DP |
AudioSessionCategoryOption.defaultToSpeaker |
AudioSessionCategoryOption.mixWithOthers,
mode: AudioSessionMode.voiceChat,
},
},
};
RNCallKeep.setSettings(options);
3. It’s also helpful to listen for the didChangeAudioRoute event to catch any audio route changes and respond accordingly:
RNCallKeep.addEventListener('didChangeAudioRoute', () => {
console.log("audio route is changed");
});
4. Lastly, double-check that the background modes for audio and voip are enabled in your Xcode project. This ensures your app can handle calls smoothly even when running in the background.
By following these steps, you’ll help keep LiveKit’s WebRTC session stable through audio route changes and background transitions. If you run into any bumps or want me to walk you through any part, just let me know—I’m here to support you!
Sources: README.md | src/RTCAudioSession.ts | callkit/README.md | README.md | How We Built a Globally Distributed WebRTC Mesh Networkdamp-kite-83575
11/03/2025, 11:14 AMtall-airline-16756
11/03/2025, 11:15 AMAudioManager.shared.audioSession.isAutomaticConfigurationEnabled = false
try AudioManager.shared.setEngineAvailability(.none)
2. Handle CallKit Audio Session Events:
func provider(_: CXProvider, didActivate session: AVAudioSession) {
do {
try session.setCategory(.playAndRecord, mode: .voiceChat, options: [
.allowAirPlay,
.allowBluetooth,
.allowBluetoothA2DP,
.defaultToSpeaker,
.mixWithOthers
])
try AudioManager.shared.setEngineAvailability(.default)
} catch {
// Handle error
}
}
func provider(_: CXProvider, didDeactivate _: AVAudioSession) {
do {
try AudioManager.shared.setEngineAvailability(.none)
} catch {
// Handle error
}
}
3. React Native Audio Route Change Handling:
RNCallKeep.addEventListener('didChangeAudioRoute', () => {
console.log("Audio route changed");
});
4. Configure Audio Session Options:
• `allowAirPlay`: Enables AirPlay audio routing
• `allowBluetooth`: Supports Bluetooth hands-free devices
• `allowBluetoothA2DP`: Supports high-quality Bluetooth audio
• `defaultToSpeaker`: Routes audio to speaker by default
• `mixWithOthers`: Allows mixing with other audio sources
5. Test and Troubleshoot:
• Make sure background modes (audio and voip) are enabled in Xcode.
• Try testing with different audio routes like speaker, Bluetooth, and wired headphones.
• Double-check that CallKit events are handled on the main thread to prevent any silent issues.
Following these steps will help ensure your audio routes change smoothly and your voice calls stay uninterrupted. If you run into any bumps or have questions, please don’t hesitate to reach out—I’m happy to help!
Sources: README.md | Docs/audio.md | README.mddamp-kite-83575
11/03/2025, 11:18 AMtall-airline-16756
11/03/2025, 11:19 AMAudioManager.shared.audioSession.isAutomaticConfigurationEnabled, which is specific to the LiveKit Swift SDK and isn’t directly available in the React Native SDK. But don’t worry, there are some great ways to achieve similar control in React Native:
1. Custom Audio Configuration:
import { AudioSession } from '@livekit/react-native';
await AudioSession.configureAudio({
ios: {
defaultOutput: 'earpiece', // or 'speaker'
},
});
2. Dynamic Audio Management:
You can use the useIOSAudioManagement hook to automatically adjust audio settings based on track publishing states, which makes things smoother for you.
3. Platform-Specific Audio Control:
On iOS, AudioSession.selectAudioOutput() lets you switch between default and force_speaker options easily.
If you’re working with CallKit and need more manual control over the audio session, you might want to explore the native Swift SDK or even build a custom native module. Please feel free to reach out if you’d like me to walk you through any of these options—I’m here to help!
Sources: Sources/LiveKit/Audio/Manager/AudioManager.swift | callkit/README.md | docs/index.htmldamp-kite-83575
11/03/2025, 1:22 PMtall-airline-16756
11/03/2025, 1:23 PMRNCallKeep.setSettings for audio calling in React Native LiveKit, here’s a friendly guide with the options you’ll want to use:
iOS Configuration:
const options = {
ios: {
appName: 'LiveKitReactNative',
includeCallsInRecents: false,
audioSession: {
categoryOptions:
AudioSessionCategoryOption.allowAirPlay +
AudioSessionCategoryOption.allowBluetooth +
AudioSessionCategoryOption.allowBluetoothA2DP +
AudioSessionCategoryOption.defaultToSpeaker,
mode: AudioSessionMode.voiceChat,
},
},
// Android settings are required for type safety but not used here
};
RNCallKeep.setSettings(options);
Here’s a quick explanation of the key options:
• `allowAirPlay`: Lets your audio route through AirPlay.
• `allowBluetooth`: Supports Bluetooth hands-free devices, so calls work smoothly.
• `allowBluetoothA2DP`: Enables high-quality Bluetooth audio for a better experience.
• `defaultToSpeaker`: Makes sure audio goes to the speaker by default.
• `mode: AudioSessionMode.voiceChat`: Tailors the audio session specifically for real-time voice communication.
These settings are designed to ensure your voice calls sound great and behave just right. If you have any questions or need a hand with this setup, please don’t hesitate to ask—I’m here to help!
Sources: example/ios/Podfile.lockbreezy-horse-36075
12/11/2025, 7:25 PMtall-airline-16756
12/11/2025, 7:26 PMRNCallKeep.setSettings does not directly configure audio calling behavior. Instead, audio settings are managed through LiveKit's AndroidAudioTypeOptions in the configureAudio method.
RNCallKeep Android Configuration:
• `alertTitle`: Title for the permissions alert
• `alertDescription`: Description for the permissions alert
• `cancelButton`: Text for the cancel button
• `okButton`: Text for the OK button
• `foregroundService`: Configuration for the foreground service, including channelId, channelName, and notificationTitle.
LiveKit Audio Configuration:
await AudioSession.configureAudio({
android: {
audioAttributesContentType: 'speech',
audioAttributesUsageType: 'voiceCommunication',
audioFocusMode: 'gain',
audioMode: 'inCommunication',
audioStreamType: 'voiceCall',
forceHandleAudioRouting: false,
manageAudioFocus: true,
},
});
These settings ensure proper audio behavior during calls. Let me know if you need further assistance with the configuration.