New initializer for ASWebAuthenticationSession

I have noticed that there is a new initializer for ASWebAuthenticationSession in macOS 14.4. The standard initializer has been deprecated without further info.

The new initializer looks as follows:

init(url: URL, callback: ASWebAuthenticationSession.Callback, completionHandler: ASWebAuthenticationSession.CompletionHandler)

This initializer takes a callback object for class ASWebAuthenticationSession.Callback.

But this class cannot be initialized and also not be subclassed. When you try to do this there will be the following error in Xcode 'init()' is unavailable

The documentation also does not give any hint on how to use it, it just defines 2 class methods and a method called func matchesURL(URL) -> Bool which could mean that by using this method you could match any arbitrary URL to continue the process.

Has anyone figured out what to do with this?

Accepted Reply

The new ASWebAuthenticationSession.Callback type can be initialized with the static members .customScheme() or .https(host:path:). The .customScheme() option is equivalent to the scheme passed to the previous initializer.

  • That makes sense. The official Apple doc does not mention anything, but I see that when you navigate to the class in Xcode directly it is explained. Thanks for that!

Add a Comment

Replies

The new ASWebAuthenticationSession.Callback type can be initialized with the static members .customScheme() or .https(host:path:). The .customScheme() option is equivalent to the scheme passed to the previous initializer.

  • That makes sense. The official Apple doc does not mention anything, but I see that when you navigate to the class in Xcode directly it is explained. Thanks for that!

Add a Comment