Revert "Native calls: upgrade to LiveKit 2.15 + add CallKit audio-session coordination"
This reverts commit 455d16abcc.
This commit is contained in:
+1
-3
@@ -93,9 +93,7 @@ workflows:
|
|||||||
- name: Install CocoaPods
|
- name: Install CocoaPods
|
||||||
script: |
|
script: |
|
||||||
cd mobile/ios/App
|
cd mobile/ios/App
|
||||||
# --repo-update refreshes the CocoaPods spec repo so it knows the latest LiveKitClient (the build box's
|
pod install
|
||||||
# cached spec repo was stale, so '~> 2.x' resolved an OLD version missing the CallKit audio API).
|
|
||||||
pod install --repo-update
|
|
||||||
|
|
||||||
- name: Build the signed IPA
|
- name: Build the signed IPA
|
||||||
script: |
|
script: |
|
||||||
|
|||||||
@@ -18,12 +18,10 @@ Pod::Spec.new do |s|
|
|||||||
s.ios.deployment_target = '14.0'
|
s.ios.deployment_target = '14.0'
|
||||||
s.dependency 'Capacitor'
|
s.dependency 'Capacitor'
|
||||||
# LiveKit iOS SDK — carries the call media NATIVELY so audio survives backgrounding AND coordinates with
|
# LiveKit iOS SDK — carries the call media NATIVELY so audio survives backgrounding AND coordinates with
|
||||||
# CallKit's audio session (auto-config OFF via AudioManager.shared.audioSession.isAutomaticConfigurationEnabled
|
# CallKit's audio session (auto-config OFF via AudioManager.shared.audioSession.isAutomaticConfigurationEnabled;
|
||||||
# + setEngineAvailability in CXProvider didActivate/didDeactivate), which the WebView's WebRTC could not do.
|
# we configure the session in CXProvider didActivate), which the WebView's WebRTC could not do. Pulls in the
|
||||||
# Pulls in the WebRTC binary transitively. PINNED to 2.15+: the CallKit audio-session coordination API
|
# WebRTC binary transitively.
|
||||||
# (AudioManager.audioSession / setEngineAvailability) only exists in 2.15+, and '~> 2.0' was resolving an
|
s.dependency 'LiveKitClient', '~> 2.0'
|
||||||
# older 2.x on the build box (see the `pod install --repo-update` in codemagic.yaml).
|
|
||||||
s.dependency 'LiveKitClient', '~> 2.15'
|
|
||||||
# CallKit + PushKit + AVFoundation are system frameworks (no external pod).
|
# CallKit + PushKit + AVFoundation are system frameworks (no external pod).
|
||||||
s.frameworks = 'CallKit', 'PushKit', 'AVFoundation'
|
s.frameworks = 'CallKit', 'PushKit', 'AVFoundation'
|
||||||
s.swift_version = '5.1'
|
s.swift_version = '5.1'
|
||||||
|
|||||||
@@ -54,21 +54,16 @@ public class NativeCallPlugin: CAPPlugin, CAPBridgedPlugin, PKPushRegistryDelega
|
|||||||
registry.delegate = self
|
registry.delegate = self
|
||||||
registry.desiredPushTypes = [.voIP]
|
registry.desiredPushTypes = [.voIP]
|
||||||
pushRegistry = registry
|
pushRegistry = registry
|
||||||
// CallKit audio coordination (needs LiveKit 2.15+, pinned in NativeCall.podspec). LiveKit's automatic
|
// NOTE: the CallKit↔LiveKit audio-session coordination (AudioManager.audioSession /
|
||||||
// AVAudioSession configuration RACES CallKit's own activation → intermittent dead mic / no audio + the
|
// setEngineAvailability) needs LiveKit 2.15+, but the build currently resolves an older 2.x that lacks
|
||||||
// output route only settling once audio flows ("speaker turns on late"). Fix: turn auto-config OFF and
|
// those symbols. So we rely on LiveKit's default audio handling for now and only configure the session
|
||||||
// keep the audio engine OFF; we configure the session and enable the engine ONLY in didActivate.
|
// with plain AVFoundation in didActivate. Revisit once the pod is pinned/upgraded to 2.15+.
|
||||||
AudioManager.shared.audioSession.isAutomaticConfigurationEnabled = false
|
|
||||||
try? AudioManager.shared.setEngineAvailability(.none)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - LiveKit media
|
// MARK: - LiveKit media
|
||||||
|
|
||||||
private func connectRoom(url: String, token: String) {
|
private func connectRoom(url: String, token: String) {
|
||||||
guard !url.isEmpty, !token.isEmpty else { return }
|
guard !url.isEmpty, !token.isEmpty else { return }
|
||||||
// Ask for mic permission now (we still connect MUTED). If it stays "undetermined", enabling the audio
|
|
||||||
// engine in didActivate can block on first use — determining it up front avoids that.
|
|
||||||
AVAudioSession.sharedInstance().requestRecordPermission { _ in }
|
|
||||||
let old = room
|
let old = room
|
||||||
let r = Room()
|
let r = Room()
|
||||||
room = r
|
room = r
|
||||||
@@ -290,20 +285,12 @@ public class NativeCallPlugin: CAPPlugin, CAPBridgedPlugin, PKPushRegistryDelega
|
|||||||
action.fulfill()
|
action.fulfill()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CallKit owns the AVAudioSession lifecycle. Since LiveKit auto-config is OFF, configure the session HERE —
|
// Keep the last known-good audio behavior (rely on LiveKit's default session handling). We only report the
|
||||||
// when CallKit activates it — and enable LiveKit's audio engine. This is the fix for the intermittent
|
// state to JS. The proper CallKit↔LiveKit session coordination is deferred until the pod is on 2.15+.
|
||||||
// dead mic / no-audio and late speaker routing. Don't call setActive(true): CallKit already activated it.
|
|
||||||
public func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
|
public func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
|
||||||
do {
|
notifyListeners("audioActivated", data: ["ok": true])
|
||||||
try audioSession.setCategory(.playAndRecord, mode: .voiceChat, options: [.mixWithOthers])
|
|
||||||
try AudioManager.shared.setEngineAvailability(.default)
|
|
||||||
notifyListeners("audioActivated", data: ["ok": true])
|
|
||||||
} catch {
|
|
||||||
notifyListeners("audioActivated", data: ["ok": false, "error": String(describing: error)])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
|
public func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
|
||||||
try? AudioManager.shared.setEngineAvailability(.none) // keep the engine off until the next call activates
|
|
||||||
notifyListeners("audioDeactivated", data: ["ok": true])
|
notifyListeners("audioDeactivated", data: ["ok": true])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user