❔ Error in iOS MAUI app when trying to use WebAuthenticator

Hello! I'm trying to write a simple mobile app that hits my own API. I wrote a wrapper for the API that triggers a new authentication with WebAuthenticator.AuthenticateAsync if there's no valid authentication session. This works if I trigger a new auth session from a button, but trying to do an API request when a view loads (from OnAppearing) gives me this on iOS:
Foundation.NSErrorException: Error Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=3 "The UIWindowScene for the returned window was not in the foreground active state." UserInfo={NSDebugDescription=The UIWindowScene for the returned window was not in the foreground active state.}
at Microsoft.Maui.Authentication.WebAuthenticatorImplementation.AuthenticateAsync(WebAuthenticatorOptions webAuthenticatorOptions)
at [...].Mobile.Services.AuthService.ForceAuthenticate() in [...]/Services/AuthService.cs:line 67
Foundation.NSErrorException: Error Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=3 "The UIWindowScene for the returned window was not in the foreground active state." UserInfo={NSDebugDescription=The UIWindowScene for the returned window was not in the foreground active state.}
at Microsoft.Maui.Authentication.WebAuthenticatorImplementation.AuthenticateAsync(WebAuthenticatorOptions webAuthenticatorOptions)
at [...].Mobile.Services.AuthService.ForceAuthenticate() in [...]/Services/AuthService.cs:line 67
Is there a specific place I should be doing this in on view initialization in order to immediately pop up the login prompt (if needed) when a view is opened? (fwiw - if this is something that would normally get an app removed from the app store, it's not really an issue I care about - this is an app only for my personal use, and has other stuff that would probably get it removed anyway like using SSO but not having appleid support for SSO 😅 )
1 Reply
Accord
Accord15mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server