Watch CallKit events natively to auto-restore WebRTC audio session#9
Draft
Copilot wants to merge 3 commits into
Draft
Watch CallKit events natively to auto-restore WebRTC audio session#9Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Co-authored-by: jerry2013 <4749863+jerry2013@users.noreply.github.com>
Co-authored-by: jerry2013 <4749863+jerry2013@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add CallKit event listeners for WebRTC session
Watch CallKit events natively to auto-restore WebRTC audio session
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a phone call interrupts a WebRTC session, the iOS audio session is taken over by CallKit/system and WebRTC cannot recover it automatically on release.
Changes
Native CallKit observer (
PluginRTCAudioController.swift)import CallKit; class now inheritsNSObjectand conforms toCXCallObserverDelegateCXCallObserverregistered ininit()onDispatchQueue.maincallObserver(_:callChanged:)tracks active call count:RTCAudioSession.sharedInstance().audioSessionDidActivate(AVAudioSession.sharedInstance())audioSessionDidDeactivate+initAudioDevices()+restoreInputOutputAudioDevice()Covers both regular PSTN calls and CallKit VoIP calls —
CXCallObserverobserves all device calls.CallKit framework (
plugin.xml)JS escape-hatch APIs (
js/iosrtc.js)For apps with their own
CXProviderthat need exact timing control over audio session transitions:These forward directly to
RTCAudioSession.sharedInstance().audioSessionDidActivate/Deactivate.💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.