Does WebAuthenticationSession require main thread?

When I try to use the new WebAuthenticationSession (introduced in iOS 16.4), it throws an error about not having a presentation context. WAS doesn't have a way to specify the context, so it must be automatic and something is messing up the automatic detection.

One thing I noticed is that my call to webAuthSession.authenticate() ends up happening off the main thread because of how the enclosing Task gets scheduled (in spite of my adding @MainActor in various places to try to get it back on track). Before I go too far down that rabbit hole, can anyone confirm that the authenticate() call will throw that presentation context error if called off the main thread?

Answered by ForumsContributor in

WebAuthenticationSession.authenticate() has no specific calling queue or actor requirements. Would you mind filing a feedback with a sample project that demonstrates the issue and sharing the number here so we can investigate this further? Thanks!

Accepted Answer

WebAuthenticationSession doesn't have any thread/queue/actor requirements. The context should get set based on where in the view tree you read the object from the environment. Can you provide sample code for the issue you're seeing?

Does WebAuthenticationSession require main thread?
 
 
Q