ASWebAuthenticationSession Async/Await API

Is there any particular reason why ASWebAuthenticationSession doesn't have support for async/await? (example below)

do {
  let callbackURL = try await webAuthSession.start()
} catch {
  // handle error
}

I'm curious if this style of integration doesn't exist for architectural reasons? Or is the legacy completion handler style preserved in order to prevent existing integrations from breaking?

Answered by Systems Engineer in 833652022

This API long predates Swift Concurrency, and hasn't received many updates since then. Existing API can't be removed, because that would break all existing apps that use it, but new API could be added! If this is something you'd like to see, please us know through Feedback Assistant.

Accepted Answer

This API long predates Swift Concurrency, and hasn't received many updates since then. Existing API can't be removed, because that would break all existing apps that use it, but new API could be added! If this is something you'd like to see, please us know through Feedback Assistant.

This makes sense. I currently work on an SDK team and we wrap this API, so naturally we like to follow the pattern of the underlying iOS framework so that it feels familiar to our customers.

I am curious if this is an architectural decision? We do want to offer async/await in our APIs wherever possible, but we aren't sure if waiting on information contained in the redirect URL is better suited for the callback pattern instead of async/await since we're technically waiting on user input and not necessarily a concurrent operation.

ASWebAuthenticationSession Async/Await API
 
 
Q