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

Handling Back Navigation in Android Version 14: Dealing with Google Authenticator Popup Dismissal

Open omeremp opened this issue 11 months ago • 6 comments

In android version 14 when the user clicks outside the pop up, and since the Google Authenticator pop up doesn't throw any exceptions, how can I navigate back to the previous screen?

omeremp avatar Mar 12 '24 09:03 omeremp

Hey @omeremp. Can you please provide more information about your problem?

What pop up do you mean, are you talking about the Google Password Manager popup? Are you talking about a login or a signup process? => Ideally mention the SDK method that you use to trigger that popup, so that I can better unterstand your use case :)

incorbador avatar Mar 15 '24 14:03 incorbador

Hey @omeremp. Can you please provide more information about your problem?

What pop up do you mean, are you talking about the Google Password Manager popup? Are you talking about a login or a signup process? => Ideally mention the SDK method that you use to trigger that popup, so that I can better unterstand your use case :)

I'm referring to the signup process. No exception is thrown when I click outside the below pop-up. This issue is occurring in Samsung pop-up. It was working fine on Android 13, but when I updated my phone to Android 14, this issue started occurring.

Screenshot_Credential Manager

omeremp avatar Mar 21 '24 10:03 omeremp

@incorbador is there any update ? Is there any further detail required ?

omeremp avatar Apr 01 '24 05:04 omeremp

@omeremp Hmm interesting. Android throws an exception if the credential creation process is interrupted. We can that one and I am not aware that something has been changed here on Android 14 (Google Pixel). I just ran the example of our passkey package on an Android 14 phone and got the exception (PasskeyAuthCancelledException). cancellation

I the tested the same example on a Samsung and I got the behaviour you described. It doesn't matter if I use Samsung Pass or Google Credential Manager, in both cases the click outside of the popup doesn't throw that Android exception.

I am afraid that we can't solve this in our packages, this appears to be a decision (or a bug by Samsung's own version of Android). If you click explicitly on "cancel" the exception is thrown btw. (but I guess that is not what you want). I did a bit of research but couldn't find any docs by Samsung.

Therefore, I think the next step here would be to reach out to Samsung. Does this answer your question or did I get something wrong?

incorbador avatar Apr 03 '24 08:04 incorbador

@incorbador @omeremp I have resolve this issue by catching and handle various events using Widgets and callbacks provided by the Flutter framework.

Step#01 Add class _MyWidgetState extends State<MyWidget> with WidgetsBindingObserver { @override void initState() { super.initState(); WidgetsBinding.instance?.addObserver(this); }

@override void dispose() { WidgetsBinding.instance?.removeObserver(this); super.dispose(); } @override void didChangeAppLifecycleState(AppLifecycleState state) { super.didChangeAppLifecycleState(state); if (state == AppLifecycleState.resumed) { // Perform actions when the app is resumed/focused print('App resumed/focused'); } } }

In this example, the _MyWidgetState class implements WidgetsBindingObserver to listen for changes in the app's lifecycle. The didChangeAppLifecycleState method is then overridden to perform actions when the app is resumed or focused.

You can similarly handle other events like input changes, visibility changes. It will print('App resumed/focused'); when user click outside on Samsung pop up , so on resumed you can perform back action

Raja1234p avatar Apr 03 '24 10:04 Raja1234p

Hey @Raja1234p. I think that's a good approach to deal with the Samsung issue => As Samsung does not expose the information that the challenge has been aborted we have to detect that from the application (this is out of scope of this package though).

incorbador avatar Apr 13 '24 13:04 incorbador