[ad_1]
I do know that this query was requested many occasions however after hours of testing I am nonetheless for one thing which works..
I attempt to load an url from a WKWebView in Swift. That is the straightforward half. On this pointed web site the consumer can begin robotically (if permission granted) the digital camera feed. This works nice from a pc with digital camera.
With this code beneath I attempt to obtain the identical purpose however natively with an iOS App in Swift. The webview is loaded, I prompted for the digital camera permission as a result of I stuffed the Infos.plist however the digital camera feed by no means begins..
If somebody has an concept ? Thanks!
import UIKit
import WebKit
import AVFoundation
class ViewController: UIViewController, WKUIDelegate, WKNavigationDelegate {
var webView: WKWebView!
override func viewDidLoad() {
tremendous.viewDidLoad()
AVCaptureDevice.requestAccess(for: AVMediaType.video) { response in
if response {
//entry granted
DispatchQueue.primary.async {
self.webView = WKWebView(body: .zero)
self.view.addSubview(self.webView)
let layoutGuide = self.view.safeAreaLayoutGuide
self.webView.translatesAutoresizingMaskIntoConstraints = false
self.webView.leadingAnchor.constraint(equalTo: layoutGuide.leadingAnchor).isActive = true
self.webView.trailingAnchor.constraint(equalTo: layoutGuide.trailingAnchor).isActive = true
self.webView.topAnchor.constraint(equalTo: layoutGuide.topAnchor).isActive = true
self.webView.bottomAnchor.constraint(equalTo: layoutGuide.bottomAnchor).isActive = true
if let url = URL(string: "https://webrtc.github.io/samples/src/content material/gadgets/input-output/") {
self.webView.load(URLRequest(url: url))
self.webView.load(URLRequest(url: url, cachePolicy: .reloadRevalidatingCacheData, timeoutInterval: 15))
}
}
}
}
}
}
[ad_2]
