Enable session cookies for iframes on a page in WkWebView / mobile Safari

I have a website that is hosted on a third-party webpage, which itself is embedded in the WkWebViewiOS app. Mobile Safari and WkWebViewreject session cookies (http-only) sent to my site, violating basically everything. Working in mobile Safari is to either enable all cookies in the settings (yuck), or instruct users to directly visit my site (therefore, it is considered a “site I visited” as far as Safari is concerned); none of them are particularly acceptable. I did not find any workarounds for WkWebView.

This question has two parts:

1) I am thinking of implementing a redirect service on my website that takes the destination URL as a parameter and simply redirects the user to that URL when the page loads. Then a third-party site can link to my redirect page with the URL set to send users directly back, with the hope that this will be considered a “visit” to my domain, allowing cookies to be downloaded.

Alternatively, a third-party site may open a new tab on my site that closes immediately upon loading. I expect this to be a less than optimal user experience, however, and therefore would prefer not to go this route.

It would be best to use the "POST for hidden iframe" trick (third-party POST pages for my domain in a hidden iframe), but since SO questions indicate that the trick is no longer working.

Are any of these viable solutions, or has Apple blocked these methods of receiving session cookies? Is there a better solution that I have not considered?

2) Is there a way to set a cookie acceptance policy using WkWebViews, how can this be done using UiWebViews? My searches for StackOverflow do not imply, but the answers I read may be based on older versions of iOS (the app requires iOS 9 +).

If WkWebViewsthere is no code application for the solution, will the mobile Safari solution work with WkWebViews?

+4
1

. WkWebView, -, iframe, . , iframe .

-, , , iframe.

, , iframe, - iframe . , .

webview, WKNavigationDelegate, , . , - , iframe. iframe .

0

Source: https://habr.com/ru/post/1668283/


All Articles