iOS Integration
Embed DocQA in an iOS app using WKWebView.
WKWebView Setup
swift
import WebKit
let config = WKWebViewConfiguration()
config.allowsInlineMediaPlayback = true
let webView = WKWebView(frame: view.bounds, configuration: config)
view.addSubview(webView)Loading the Widget
Option 1 — Load your website (widget is already embedded):
swift
let url = URL(string: "https://yoursite.com")!
webView.load(URLRequest(url: url))Option 2 — Load the widget directly via inline HTML:
swift
let html = """
<!DOCTYPE html>
<html>
<head><meta name="viewport" content="width=device-width, initial-scale=1.0"></head>
<body>
<script
src="https://widget.webnav.ai/widget/chat-widget.js"
data-base-url="https://yoursite.com"
data-theme="light"
data-lang="en"
></script>
</body>
</html>
"""
webView.loadHTMLString(html, baseURL: URL(string: "https://yoursite.com"))App Transport Security
DocQA uses HTTPS by default, so no ATS exceptions are needed. If you are self-hosting over HTTP during development, add to Info.plist:
xml
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>SwiftUI
swift
import SwiftUI
import WebKit
struct DocQAView: UIViewRepresentable {
func makeUIView(context: Context) -> WKWebView {
let webView = WKWebView()
let url = URL(string: "https://yoursite.com")!
webView.load(URLRequest(url: url))
return webView
}
func updateUIView(_ uiView: WKWebView, context: Context) {}
}Troubleshooting
| Issue | Solution |
|---|---|
| Widget not loading | Verify internet permissions and ATS settings |
| Keyboard overlaps input | Set scrollView.contentInsetAdjustmentBehavior = .automatic |
| Small text | Ensure the viewport meta tag is included in inline HTML |