I am trying to develop an application that uses wkwebview and WebRTC to make voice calls, the app loads a wkwebview with the web page that uses webrtc and when it plays the audio of the calls it does so through the main speaker of the Iphone instead of playing the audio through the earspeaker as a normal call would. I think it recognizes the audio as multimedia and not as the audio of a call. How can I fix this issue?
import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {
@IBOutlet weak var showWebview: WKWebView!
var webView: WKWebView!
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback = true
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string:"https://mywebsite.com)
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
}