|
23 | 23 | import androidx.credentials.exceptions.GetCredentialException; |
24 | 24 | import androidx.credentials.exceptions.NoCredentialException; |
25 | 25 | import androidx.credentials.exceptions.publickeycredential.CreatePublicKeyCredentialDomException; |
| 26 | +import androidx.credentials.exceptions.publickeycredential.CreatePublicKeyCredentialException; |
26 | 27 | import androidx.credentials.exceptions.publickeycredential.GetPublicKeyCredentialDomException; |
27 | 28 |
|
28 | 29 | import com.corbado.passkeys_android.models.login.AllowCredentialType; |
@@ -105,7 +106,10 @@ public void onResult(CreateCredentialResponse res) { |
105 | 106 | @Override |
106 | 107 | public void onError(CreateCredentialException e) { |
107 | 108 | Exception platformException = e; |
108 | | - if (e instanceof CreateCredentialCancellationException) { |
| 109 | + if (Objects.equals(e.getMessage(), "Unable to create key during registration")) { |
| 110 | + // currently, Android throws this error when users skip the fingerPrint animation => we interpret this as a cancellation for now |
| 111 | + platformException = new Messages.FlutterError("cancelled", e.getMessage(), ""); |
| 112 | + } else if (e instanceof CreateCredentialCancellationException) { |
109 | 113 | platformException = new Messages.FlutterError("cancelled", e.getMessage(), ""); |
110 | 114 | } else if (e instanceof CreatePublicKeyCredentialDomException) { |
111 | 115 | if (Objects.equals(e.getMessage(), "User is unable to create passkeys.")) { |
@@ -179,7 +183,12 @@ public void onResult(GetCredentialResponse res) { |
179 | 183 | @Override |
180 | 184 | public void onError(GetCredentialException e) { |
181 | 185 | Exception platformException = e; |
182 | | - if (e instanceof GetCredentialCancellationException) { |
| 186 | + Log.e(TAG, "onError called", e); |
| 187 | + |
| 188 | + // currently, Android throws this error when users skip the fingerPrint animation => we interpret this as a cancellation for now |
| 189 | + if (Objects.equals(e.getMessage(), "None of the allowed credentials can be authenticated")) { |
| 190 | + platformException = new Messages.FlutterError("cancelled", e.getMessage(), ""); |
| 191 | + } else if (e instanceof GetCredentialCancellationException) { |
183 | 192 | platformException = new Messages.FlutterError("cancelled", e.getMessage(), ""); |
184 | 193 | } else if (e instanceof NoCredentialException) { |
185 | 194 | platformException = new Messages.FlutterError("android-no-credential", e.getMessage(), ""); |
|
0 commit comments