We need to add query parameter (isfromMobile=true ) in every webpage URL, which is required to identify that the request is from the mobile app at the backend. it's absolutely fine loading on the first page, however, if I click on the link inside webview the url changes which is completely a new URL for backend system, As per the logic, mobile app should embed query parameter on this URL as well. I tried fixing the same with following delegate method of webview.
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
request.url = request.url?.getMobileUrl() // this adds the query parameter in url eg : testurl?isFromMobile=true
return true
}
However, I observed the request parameter is not mutable in this delegate, creating everytime a new request will definitely increase the web URL loading time or I would not prefer that. Any better suggestion for the same.