Post

Replies

Boosts

Views

Activity

How can I initiate a new URL request using an already loaded WKWebView?
I have opened a WKWebView with "https://www.google.com", for example. After that, I put my app in the background. When I try to open a new URL request in the same web view with a new link, like "https://www.youtube.com", by redirecting the app, it doesn't work. I've put a listener function to detect the new URL and called "webView.load(newURLRequest)". However, the web view never loads the new URL request. I have tried to solve this issue by adding a delay through DispatchQueue. Adding a delay sometimes works and sometimes doesn't. I also tried using NavigationDelegate, but it still didn't help. Below is my code: override func viewDidLoad() { super.viewDidLoad() NotificationCenter.default.addObserver(self, selector: #selector(self.refreshData), name: NSNotification.Name("refreshweb"), object: nil) } @objc func refreshData() { let url = URL (string: "https://www.youtube.com") let requestObj = URLRequest(url: url!) webview.load(requestObj) }
0
0
368
Jul ’24
Not able to set Origin in request header in WKWebview
I have an iOS app centred around a WKWebView loading local web assets with loadFileURL. The WKWebView communicates over HTTPS to a backend API. We have made some changes at back end and due to that we need to send some app specific values for Origin of request header. In case my case value is getting replace by some default value as file://. I'm getting CORS issue while loading my application. Can I change the origin of the WKWebView to xyz to avoid browsers from querying the API?
0
0
367
Nov ’23