When user dismisses hint dialog (intent) the future we are waiting for the response should at least return null.
Actual behavior
When user disposes the hint by pressing the barrier or the 'X' button the hint method will not recognize it and will keep waiting for response, there is not even a thrown error.
For a system that validates user's phone number by this hint, this makes system more unreliable. Ofc we can still get the phone number in some differant ways but in my way I would try to pick phone number by this dialog then try to otp. If the user validates phone number by this dialog there is no need to validate by OTP right (?).
Question: Can this dialog faked? I mean this dialog only works when the SIM's phone number detected and shows multiple numbers when multiple sims atached.
Note: You can replace Log methods with 'debugPrint'
class OtpHelper {
static OTPInteractor? _instance;
static OTPInteractor get interactor => _instance ??= OTPInteractor();
///
/// Shows a dialog when the device has google services integrated.
/// User may select their phone number to autofill it.
///
static Future<String?> showGoogleHint() async {
if (Platform.isAndroid) {
try {
Log.debug('[OtpHelper] Getting phone hint');
var phoneNumber = await interactor.hint.onError((error, stackTrace) {
Log.warning('[OtpHelper] Hint returned error: $error');
return null;
});
if (phoneNumber != null) {
Log.trace('[OtpHelper] Phone number by hint: $phoneNumber');
}
return phoneNumber;
} catch (_) {
return null;
}
}
return null;
}
// ...
}
What did you try to solve
In my app, by using OTP, im checking if the device's phonenumber same with the user's. So first im showing this dialog, if it is not responding the valid phone number then starting the otp procedure.
By not waiting the dialog this problem can be solved, but while user waiting/reading the dialog the OTP timer will ticking behind. Since Im not awaiting it. Also when the message arrive, there will be another dialog shown on top of hint to allow the message read.
Any possible solutions
I tryed to edit the source code of this package and make the intent return errors incase of unexpected results.
On OTPPlugin line 120:
credentialPickerRequest -> if (resultCode == Activity.RESULT_OK && data != null) {
val phoneNumber =
Identity.getSignInClient(context!!).getPhoneNumberFromIntent(data)
lastResult?.success(phoneNumber)
lastResult = null
} else if(data == null) {
lastResult?.error("1001", "Intent did not return with data", null)
lastResult = null
} else {
lastResult?.error("1002","Intent did not return OK", null)
lastResult = null
}
and this made my code work as intended.
Feature Request
Just like in solution 2, This hint dialog need more options. We may need to know that
the dialog did not shown at all,
user dismissed the dialog,
dialog returned ne data.
This can be done by throwing erros or maybe a data class response with a status in it.
Also is there a way to know that this phone supports 'hint' ?
Expected behavior
When user dismisses hint dialog (intent) the future we are waiting for the response should at least return null.
Actual behavior
When user disposes the hint by pressing the barrier or the 'X' button the hint method will not recognize it and will keep waiting for response, there is not even a thrown error.
For a system that validates user's phone number by this hint, this makes system more unreliable. Ofc we can still get the phone number in some differant ways but in my way I would try to pick phone number by this dialog then try to otp. If the user validates phone number by this dialog there is no need to validate by OTP right (?).
Question: Can this dialog faked? I mean this dialog only works when the SIM's phone number detected and shows multiple numbers when multiple sims atached.
Details
Flutter version: 3.19.6 Dart version: 3.3.4 Platform: Android (Real Device on Debug)
Code sample
Note: You can replace Log methods with 'debugPrint'
What did you try to solve
In my app, by using OTP, im checking if the device's phonenumber same with the user's. So first im showing this dialog, if it is not responding the valid phone number then starting the otp procedure. By not waiting the dialog this problem can be solved, but while user waiting/reading the dialog the OTP timer will ticking behind. Since Im not awaiting it. Also when the message arrive, there will be another dialog shown on top of hint to allow the message read.
Any possible solutions
I tryed to edit the source code of this package and make the intent return errors incase of unexpected results. On OTPPlugin line 120:
and this made my code work as intended.
Feature Request
Just like in solution 2, This hint dialog need more options. We may need to know that
Also is there a way to know that this phone supports 'hint' ?