I am trying to build a simple Application for IOS, which is showing me a Webpage which functions as a QRCode Scanner. When i am visiting the webpage "qrcodescan.in" with safari on my phone, it accesses my iPhone Camera without any problems.
And this is how it looks when i Run the Application on my phone.
So as an application i can't access my phone camera, but on the website via Safari it is accessible.
The following is my Code in Xcode.
import UIKit
import WebKit
class ViewController: UIViewController,WKUIDelegate {
var webView: WKWebView!
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string:"https://qrcodescan.in")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
}
Also I added all Keys into "info.plist" for accessing the Camera function on the Phone.
<key>NSCameraUsageDescription</key>
<string>${PRODUCT_NAME} Camera Usage</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>${PRODUCT_NAME} library Usage</string>
So i searched a lot on the web to find anything helpful and wasn't successful. I hope somebody can help me.
Also to mention. I am absolute newbie when it comes to Swift or IOS App development in General.
Thanks in advance.