1

I need to display a website in SFSafariViewController in an iPad app. The website (an SAP Analytics Cloud Site) continuously asks the user for showing a Popup for authentication and although the toggles in the device's preferences are already set to allow pop-ups, this alert keeps showing up every time a popup is triggered. The "Allow" decision is not even persisted for the current session.

--> Is there a possibility to allow it automatically so that the user does not see this alert?

I'm not planning an AppStore release whatsoever so any hacky solutions are definitely welcome!

Unfortunately, WebKit did not work so far and I also know the dialogue is system-triggered and an Apple-side privacy requirement, but in my use case it must not be shown by all means.

Pop-Up

emmics
  • 994
  • 1
  • 11
  • 29
  • 1
    This isn't something that you should be doing. Even if it's not going to be published to the app store, Apple built this window so it can't be edited by the presenting view. I'm curious why you need to use popups and maybe there's a solution in changing that requirement. – thecoolwinter Nov 16 '21 at 18:41
  • 1
    @thecoolwinter to be precise, a SAP Analytics cloud application opened in the Safari is doing background-authentication using popups. They'll automatically close on a desktop version where they are almost unnoticeable. If the dialog from above would show up only one time and the decision is remembered that would be acceptable but it's shown every single time, which is not an option. – emmics Nov 16 '21 at 19:11

1 Answers1

1

I developed an app accessing an SAP Analytics Cloud site once and had the same problem. I couldn't solve it with SFSafariViewController at first, so I decided to go with WKWebView. Eventually, it worked for me this way:

  • Enable Cross Site Tracking for the App. To do so you have to provide a NSCrossWebsiteTrackingUsageDescription in the Info.plist and also add a Settings.bundle file. (See Using NSCrossWebsiteTrackingUsageDescription to request user disable ITP for WKWebView). Doing so, the Authentication using Popups worked flawlessly.
  • Implement the webView(webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? function from WKUIDelegate to create a small „Popup Webview“. In your use case, you can set the frame to .zero to make it invisible. Just make sure you return a WKWebView.
  • Implement webViewDidClose(_ webView: WKWebView) from WKUIDelegate to remove the popup from the superview once the Authentication completed.
Tobias Geiselmann
  • 2,139
  • 2
  • 23
  • 36