ioswebrtccapacitorcoturn

iOS and TURN within Capacitor build


WebRTC works in Safari on iOS cellular but not in WKWebView/Capacitor. TURN relay candidates generated, but ICE checks stuck. Is there an iOS entitlement or WKWebView configuration needed for TURN relay on cellular networks?

Safari on iOS cellular works with pi-webrtc. Capacitor iOS app on cellular generates TURN relay candidates but connection stuck at 'checking' state. Coturn shows zero peer data relayed. TURN allocations succeed, permissions created, but no media flows. Same code works in Safari browser. Is there a known WKWebView limitation for TURN relay on cellular?

And for what it is worth, Ionic-Vue Capacitor build on Android also works with cellular (WAN) connection... and ALL variations work on the LAN.

In XCode, App > Signing and Capabilities, I set Mic and Camera permission.

Any clues would be really appreciated!


Solution

  • A few things, is NSLocalNetworkUsageDescription in your Info.plist?

    Also, I think you also may need to activate AVAudioSession before WebRTC starts. You'll also need to force TURN over TCP (port 443) instead of UDP; also make sure you've disabled iCloud Private Relay on your test device.

    If none of the above work, consider using a native WebRTC library instead of WKWebView's built-in implementation.