auth0 / auth0-flutter

Auth0 SDK for Flutter
https://pub.dev/documentation/auth0_flutter/latest/
Apache License 2.0
57 stars 36 forks source link

The UIWindowScene for the returned window was not in the foreground active state - iOS #462

Open kane-knowby opened 4 weeks ago

kane-knowby commented 4 weeks ago

Checklist

Description

If you call the web authentication login method too fast after app is brought to the foreground, the login fails with the following error:

`WebAuthenticationException (OTHER: An unexpected error occurred. CAUSE: 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.}) [K] #0 MethodChannelAuth0FlutterWebAuth.invokeRequest (package:auth0_flutter_platform_interface/src/method_channel_auth0_flutter_web_auth.dart:45:7)

#1 MethodChannelAuth0FlutterWebAuth.login (package:auth0_flutter_platform_interface/src/method_channel_auth0_flutter_web_auth.dart:21:9) #2 WebAuthentication.login (package:auth0_flutter/src/mobile/web_authentication.dart:89:25) #3 AuthService.acceptInvite (package:knowby_pro/features/auth/state/auth_service.dart:368:27) ` We are only able to get around this by adding a fake delay before calling the login method. ### Reproduction 1. Create a new flutter route in the example which calls web auth login as soon as the route loads 2. Deeplink to that route when app is in the background (iOS) ### Additional context _No response_ ### auth0_flutter version 1.7.2 ### Flutter version 3.22.0 ### Platform iOS ### Platform version(s) iOS 17.5