Swift

Overview

Show the merged observability metrics on top of the call UI so you can see live quality data during a session. Based on what you observe, you can add thresholds later (for example, show a poor-connection message when networkDegradationSource is .local).

Display Stats in the UI

Use a small ObservabilityStats model in your project to hold overlay fields (bandwidth, packet loss, degradation source, network condition labels).

1. Host Publisher and Subscriber Views

Reuse a UIViewRepresentable wrapper (as in the Basic video chat (Swift) tutorial) to embed OTPublisher and OTSubscriber views in SwiftUI:

struct VideoCallView: View {
    @ObservedObject var videoManager: VonageVideoManager

    var body: some View {
        ZStack {
            VStack {
                if let pubView = videoManager.pubView {
                    Wrap(view: pubView)
                        .frame(height: 200)
                }
                if let subView = videoManager.subView {
                    Wrap(view: subView)
                        .frame(maxHeight: .infinity)
                }
            }

            if let stats = videoManager.latestObservabilityStats {
                StatsOverlay(stats: stats)
            }
        }
    }
}

2. Stats Overlay

struct StatsOverlay: View {
    let stats: ObservabilityStats

    var body: some View {
        VStack(alignment: .leading, spacing: 4) {
            Text("Observability")
                .font(.headline)
            Text(stats.summaryLines.joined(separator: "\n"))
                .font(.system(.caption, design: .monospaced))
        }
        .padding(12)
        .background(.black.opacity(0.6))
        .foregroundColor(.white)
        .cornerRadius(8)
        .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
        .padding()
    }
}

Wire @Published var latestObservabilityStats on VonageVideoManager so SwiftUI refreshes when delegate callbacks update state on the main queue.

3. iOS App Lifecycle

iOS-specific: Unlike the Android SDK’s session.onPause() / onResume(), iOS apps typically rely on ScenePhase, audio session interruptions, and your own policy when backgrounding during a call. If the app backgrounds, stats may pause or stop until the session is active again—test on a physical device for realistic network behavior.

Next: Run with a second participant and confirm the overlay updates.