iOS-MAS-Foundation
iOS-MAS-Foundation copied to clipboard
Add option for user to select browser type to use for browser based authentication
Issue
Currently a SFSafariViewController
is used for browser based authentication. This is fine as long as cookie sharing is not needed between multiple browser instances; However some social logins, especially ones using the app to authenticate the user, require these cookies to be shared. As of iOS 11, SFSafariViewController
does not share cookies with the Safari app, nor any other browser instance. As of iOS 11 Apple introduced dedicated authentication sessions to handle authenticating a user through a social login: SFAuthenticationSession(deprecated), and shortly after ASWebAuthenticationSession.
Changes
This PR adds the option for users to select which type of browser based authentication type they want to use SFSafariViewController
or ASWebAuthenticationSession
. The latter is only available if the user is running on a target which supports it (>= iOS 12, >= OSX 10.15).
This can be done by setting it on the top level MAS object:
// objc
[MAS preferredBrowserBasedAuthenticationType:MASBrowserBasedAuthenticationTypeSafari];
// swift
MAS.preferredBrowserBasedAuthenticationType(.safari)
Upon starting browser based authentication, the preferred browser type will be used, instead of the default SFSafariViewController
.
Future Changes
Currently there is a gap for iOS 11 users, as ASWebAuthenticationSession
is still available from iOS 12 and onwards. We could opt to also support the deprecated SFAuthenticationSession
if needed.