I'm trying to create a simple app with a website embedded using WebView, everything works fine except that I don't understand how I would authenticate against a website that requires credentials.
I've searched the web for several hours and finally given up on finding an answer. Might just be that I don't know what wording to use.
Hope anyone on here knows a way either to hardcode the credentials or preferably a way for the user to enter their own credentials.
Thank you!
The code I'm using is the easiest possible, as follows:
import SwiftUI
import WebKit
struct ContentView: View {
var body: some View {
NavigationView {
VStack {
WebView(request: URLRequest(url: URL(string: "https://siteurl")!))
}.navigationBarTitle("Example Text")
}
}
}
struct WebView: UIViewRepresentable {
let request: URLRequest
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView: WKWebView, context: Context) {
uiView.load(request)
}
}