In my application I am implementing a feature where for some part I need to open my website using SFSafariViewController. For this I don't want the user to login again in the web application as well, so before I open the SFSafariViewController I want to pass some token, mail and other required information. So is this feasible and would allow me to use browser cache.
1 Answers
SFSafariViewController
is very limited in what you can configure, as seen by the documentation: https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller. Apple intentionally keeps cookies and safari configuration separate from apps that are using it for security and privacy reasons.
I don't know if this is exactly what you're seeing, but I faced a similar issue where, if a user logged in via SFSafariViewControler
, then logged out (not using SFSafariViewController
), then logged in again, it wouldn't ask for a login/pass because it was still cached in the browser.
Pretty much the only 2 options for this are:
- Have the logout flow take place within
SFSafariViewController
so that you can clear the cookies that way. - Apple has a new auth flow class
ASWebAuthenticationSession
(docs here) which has a new property you can set calledprefersEphemeralWebBrowserSession
which essentially opens the browser in private mode. This keeps any cookies from being stored in the browser. The only downside to this, is theprefersEphemeralWebBrowserSession
property is only available in iOS 13+.
If this is the same issue you're facing and you can limit your app to iOS 13+, then I would suggest the ASWebAuthenticationSession
route, otherwise you may need to find another solution.