简体   繁体   English

在WKWebView中显示“使用相机”选项

[英]Show the 'Use camera' option in the WKWebView

I'm implementing a WKWebView that loads a payment page with credit card information; 我正在实现一个WKWebView,该页面会加载带有信用卡信息的付款页面; I need to show the 'Use camera' option along with the keyboard just like safari browser. 我需要像野生动物园浏览器一样,在键盘上显示“使用相机”选项。

I have added the camera permission for the info.plist, but nothing is working on the webview!! 我已经为info.plist添加了摄像头权限,但是在webview上什么都没用! Should I select a specific keyboard? 我应该选择特定的键盘吗?

I am using iOS 11 with swift 3.2 or 4.0 我正在将iOS 11与Swift 3.2或4.0一起使用

Here it is my code 这是我的代码

    var webView : WKWebView = WKWebView()
    let configuration = WKWebViewConfiguration()   
    webView = WKWebView(frame: CGRect.zero, configuration: configuration)      
    webView.frame = CGRect(x: 0, y: 20, width: self.view.bounds.width, height: self.view.bounds.height)       
    webView.navigationDelegate = self
    webView.uiDelegate = self
    webView.scrollView.delegate = self
    webView.backgroundColor = UIColor.black
    webView.isMultipleTouchEnabled = false
    self.view.addSubview(webView)

    let newurl = URL(string:"https://xxxxxxxxx")
    let newrequest = URLRequest(url: newurl!)                    
    self.webView.load(newrequest)

plus Camera permission 加上相机许可

Key       :  Privacy - Camera Usage Description   
Value     :  $(PRODUCT_NAME) Use camera

After long research I found SFSafariViewController with its delegate class SFSafariViewControllerDelegate could be used to show the scan card option available on safari, but with limited capabilities compared to the WKWebView, so it's up to your business case to use it or not, but anyway this is the only option available right now according to my knowledge. 经过长期的研究,我发现SFSafariViewController其委托类SFSafariViewControllerDelegate可以用来显示扫描卡选件可在Safari浏览器,但与有限的能力相比WKWebView,所以就看你的商业案例来使用与否,但无论如何,这是据我所知,目前唯一可用的选项。

Please note that, in order to make it work, you should enable the scan card option on your mobile by changing the settings under the privacy. 请注意,为了使其正常工作,您应该通过更改隐私下的设置来启用手机上的扫描卡选项。

Also, you need to be sure that the payment page includes the iOS meta tags to let safari detect the credit card fields. 另外,您需要确保付款页面包含iOS meta标签,以使safari可以检测信用卡字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM