-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Use case
I'd like to suggest some changes to the error handling for the biometric authentication features provided by the local_auth library.
Currently, there are some differences in how errors are handled on iOS and Android.
I'm particularly focused on one specific situation on iOS: when iOS biometric authentication is voluntarily cancelled by the user.
Proposal
- For cases when iOS biometric authentication is voluntarily cancelled by the user:
Currently, when a user voluntarily cancels the iOS biometric authentication, a PlatformException with error PlatformException(NotAvailable, Authentication canceled., com.apple.LocalAuthentication, null) is returned on Flutter's end.
This PlatformException is indistinguishable from the PlatformException(NotAvailable, Authentication failure., com.apple.LocalAuthentication, null) returned when biometric authentication fails consecutively.
This makes it difficult to properly handle each exception.
However, on Android, when a user voluntarily cancels the authentication, the return value of LocalAuthentication().authenticate() is false.
Therefore, to make it easier to differentiate between the two exceptions, I propose that for voluntarily cancelled iOS biometric authentication, like Android, the return value of LocalAuthentication().authenticate() should be false.
I believe that this can be achieved by adding kLAErrorUserCancel to the iOS source code.
I believe that the issue could be resolved by writing a code as follows.

