auth0-flutter icon indicating copy to clipboard operation
auth0-flutter copied to clipboard

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

Open kane-knowby opened this issue 8 months ago • 0 comments

Checklist

  • [X] The issue can be reproduced in the auth0_flutter sample app (or N/A).
  • [X] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • [X] I have looked into the API documentation and have not found a suitable solution or answer.
  • [X] I have searched the issues and have not found a suitable solution or answer.
  • [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • [X] I agree to the terms within the Auth0 Code of Conduct.

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) <asynchronous suspension> #1 MethodChannelAuth0FlutterWebAuth.login (package:auth0_flutter_platform_interface/src/method_channel_auth0_flutter_web_auth.dart:21:9) <asynchronous suspension> #2 WebAuthentication.login (package:auth0_flutter/src/mobile/web_authentication.dart:89:25) <asynchronous suspension> #3 AuthService.acceptInvite (package:knowby_pro/features/auth/state/auth_service.dart:368:27) <asynchronous suspension>

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

kane-knowby avatar Jun 06 '24 07:06 kane-knowby