Best practices using the Video SDK in an iOS WebView

Zoom recommends using the Video SDK for iOS in native iOS apps. However, if you are optimizing your iOS app for package size, the Video SDK for web can be embedded in an iOS WebView. This is now supported in Video SDK for web 1.5.5 and above.

Here are the best practices for using the Video SDK for web in an iOS WebView:

  1. Configure your App's Info.plist file to include the NSCameraUsageDescription and NSMicrophoneUsageDescription properties.

  2. Add the WebKit WKWebView code in your ViewController.swift file. Here is a great video that demonstrates this. (The part in the video about JavaScript injection and User Agents is not required). In addition to the video, make sure to include the following in your webView class:

    configuration.allowsInlineMediaPlayback = true
    

    Here is a full example implementation:

    import UIKit
    import WebKit
    classViewController: UIViewController {
        let webView: WKWebView = {
            let prefs = WKWebpagePreferences()
            prefs.allowsContentJavaScript = true
            let configuration = WKWebViewConfiguration()
            configuration.defaultWebpagePreferences = prefs
            configuration.allowsInlineMediaPlayback = true
            let webView = WKWebView(frame: .zero, configuration: configuration)
            return webView
        }()
        override func viewDidLoad() {
            super.viewDidLoad()
            view.addSubview(webView)
            guardlet url = URL(string: "https://example.com/videosdk") else {
                return
            }
            webView.load(URLRequest(url: url))
        }
        override func viewDidLayoutSubviews() {
            super.viewDidLayoutSubviews()
            webView.frame = view.bounds
        }
    }