Post

Replies

Boosts

Views

Activity

Reply to Choose the file directory of my files
I'm not sure if I understand your question correctly. However, you should add these json files to your main bundle, make sure you add them to your project in Xcode. Collecting them should then look like this:  let jsonUrl = Bundle.main.url(forResource: "yourJson", withExtension: "json")! I hope this helps you.
Dec ’21
Reply to Access camera and microphone in WKWebView
This is possible, but you have to use a workaround. First of all you indeed need to set your permissions in the info.plist. <key>NSMicrophoneUsageDescription</key> <string>If you want to use the microphone, you have to give permission.</string> <key>NSCameraUsageDescription</key> <string>If you want to use the camera, you have to give permission.</string> After this you have to inject Javascript at the start of the document of the WebView. You could to this by adding a .js document to your project. the code in here would look like this: //injects this into webpage to listen to the camera request (function() {   if (!window.navigator) window.navigator = {};     //if getuserMedia is called -> If the user requests native camera         window.navigator.getUserMedia = function() {             webkit.messageHandlers.callbackHandler.postMessage(arguments);   } })(); In your viewController file, injecting this into the WebView would look like this:  override func loadView() {         let userScriptURL = Bundle.main.url(forResource: "UserScript", withExtension: "js")!         let userScriptCode = try! String(contentsOf: userScriptURL)         let userScript = WKUserScript(source: userScriptCode, injectionTime: .atDocumentStart, forMainFrameOnly: false)         let webConfiguration = WKWebViewConfiguration()         webConfiguration.userContentController.addUserScript(userScript) } This works for both camera and microphone use like you are trying to do.
Dec ’21