MapServer does not load from WKWebView but works in both UIWebView and Safari

694
3
07-10-2020 03:29 PM
HectorMeneses
New Contributor II

Hi,

I have an application that needs to use WKWebView to display a map. This is a requirement from Apple as UIWebView will be deprecated by the end of this year.

In both UIWebView and Safari, the website with a map gets displayed correctly  but in the WKWebView the following call generates an error:

https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json 

"An error occurred trying to load the resource".

As result, the map is never displayed.

Has anyone experienced this issue?

Thanks!

0 Kudos
3 Replies
HectorMeneses
New Contributor II

I modified my app to point to the following site in esri:

https://developers.arcgis.com/javascript/3/

the app using WKWebView fails to display the sample map.

However, if I use safari in the iPad simulator the same page displays the sample map without trouble.

Here it is with WKWebView:

esri sample map does not display in WKWebview

The same page displays just fine in the iPad simulator safari browser:

esri sample map displays in safari

Anybody else has this issue?

0 Kudos
KasperRasmussen
New Contributor

Hi,

I have the same problem.

I get the following error running it on my iPad "Request header field Cache-Control is not allowed by Access-Control-Allow-Headers".

Have you found a solution to the problem?

Br.

Kasper

0 Kudos
HectorMeneses
New Contributor II

Hi Kasper,

The error we were facing was related to the handling of self signed certificates in the didReceiveAuthenticationChallenge method. Basically, we were cancelling all requests if they didn't match one of our host domains. Instead we needed to call PerformDefaultHandling in the completionHandler.

I think your issue is different... it sounds like the server side needs to change to allow Cache-Control in your Access-Control-Allow-Headers setting.