Skip to content

Blocking engine availability method call when microphone permission is not determined #815

@silviudeac

Description

@silviudeac

Our phone application uses CallKit and the LiveKit iOS Client SDK for making and receiving phone calls.

Calling AudioManager's "setEngineAvailability(.default)" when the microphone permission is not determined (AVAuthorizationStatus.notDetermined) will block the calling thread.

Example usage:

class CallKitDelegate: CXProviderDelegate {

    func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
        do {
            try AudioManager.shared.setEngineAvailability(.default)
        } catch {
            print("Error setting engine availability: \(error)")
        }
    }
}

This will block until the user gives his permission (a permission dialog will appear if the application is running in the foreground).
This is acceptable for when the app is in foreground, but consider that the application may be running in the background when an incoming call arrives in which case the permission dialog will not appear and the application will be blocked.

We can implement a workaround but I believe it would be preferable for the method to throw rather than block.

SDK Version
2.8.1

iOS/macOS Version
iOS 26.0.1

Xcode Version
Xcode 26.0, Swift 6.2

Steps to Reproduce
Requirements:

  • an iOS application that uses the CallKit SDK
  • microphone permission not determined (user was not asked yet)
  • call 'AudioManager.shared.setEngineAvailability(.default)' after CallKit activates the AVAudioSession and reports it in it's delegate.

Expected behavior
Throw an error if the setEngineAvailability cannot complete successfully due to the missing microphone permission.

Screenshots
Image

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions