getSmsWithUserConsentApi method
Starts listening to SMS User Consent API https://developers.google.cn/identity/sms-retriever/user-consent/overview Which shows confirmations dialog to user to confirm reading the SMS content returns code if it matches with matcher
Implementation
Future<SmartAuthResult<SmartAuthSms>> getSmsWithUserConsentApi({
/// used to extract code from SMS
String matcher = _defaultCodeMatcher,
/// Optional parameter for User Consent API
String? senderPhoneNumber,
}) async {
try {
final result = await _api.getSmsWithUserConsentApi(senderPhoneNumber);
return SmartAuthResult.success(
SmartAuthSms.fromSms(result, matcher),
);
} catch (error) {
final isCanceled = error is PlatformException &&
error.details is SmartAuthRequestCanceled;
if (isCanceled) {
debugPrint('Pinput/SmartAuth: ${error.message}');
return SmartAuthResult.canceled();
}
debugPrint('Pinput/SmartAuth: getSmsWithUserConsentApi failed: $error');
return SmartAuthResult.failure(
'Failed to get SMS with user consent API with error: $error',
);
}
}