I am looking for solution for iOS 13
SDK WKWebview
based app built with SwiftUI
in order to make cookies saved between different sessions of app usage.
This problem has been numerously discussed acrossed stackoverflow provided with different soltuions for ObjectiveC
and Swift
with Storyboards
.
I am asking the community if there is ready to use code examlpe of how to provide WKWebView
Cookie Persistency on iOS 13
WKWebView
app with SwiftUI
used
To make it clear: my app accesses remote web server with web site designed to be like mobile app. It's not local web app with need to manipulate cookies locally. Simply to make cookies manipulation in web site from remote server in Jquery JS
code of the page in order to work and be saved across different sessions of app,
My current version of code:
import SwiftUI
import WebKit
struct ContentView: View {
var body: some View {
WebView().edgesIgnoringSafeArea(.all)
}
}
struct WebView: UIViewRepresentable {
func makeUIView(context: Context) -> WKWebView {
let webView = WKWebView()
webView.scrollView.isScrollEnabled = false
return webView
}
func updateUIView(_ webView: WKWebView, context: Context) {
let liveView = "https://example.com/projectname/index.html"
if let url = URL(string: liveView) {
let request = URLRequest(url: url)
webView.load(request)
}
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif