mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-29 18:00:26 -06:00
fix: Trust server in the iOS webview to allow to load the survey package (#5024)
This commit is contained in:
committed by
GitHub
parent
6a2a8b74c8
commit
d98eb5b46f
@@ -26,6 +26,7 @@ struct SurveyWebView: UIViewRepresentable {
|
||||
webView.isOpaque = false
|
||||
webView.backgroundColor = UIColor.clear
|
||||
webView.isInspectable = true
|
||||
webView.navigationDelegate = context.coordinator
|
||||
webView.uiDelegate = context.coordinator
|
||||
return webView
|
||||
}
|
||||
@@ -51,7 +52,7 @@ struct SurveyWebView: UIViewRepresentable {
|
||||
}
|
||||
|
||||
extension SurveyWebView {
|
||||
class Coordinator: NSObject, WKUIDelegate {
|
||||
class Coordinator: NSObject, WKUIDelegate, WKNavigationDelegate {
|
||||
// webView function handles Javascipt alert
|
||||
func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
|
||||
let alertController = UIAlertController(title: "", message: message, preferredStyle: .alert)
|
||||
@@ -59,6 +60,14 @@ extension SurveyWebView {
|
||||
UIApplication.safeKeyWindow?.rootViewController?.presentedViewController?.present(alertController, animated: true)
|
||||
completionHandler()
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||
if let serverTrust = challenge.protectionSpace.serverTrust {
|
||||
completionHandler(.useCredential, URLCredential(trust: serverTrust))
|
||||
} else {
|
||||
completionHandler(.useCredential, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user