Reputation: 25
Getting error message during OTP auto fill process
Environment is: Flutter Release Build Flutter framework version 3.16.5 Mobilde device: Samsung Galaxy s23 ultra and S23. On other devices OTP reading and filling in OTP page is working fine.
Debugging using VSCode
Error received: There was a problem connecting. Try again later.
Issue is specific to this phone only so we want to catch the exception to know which package and why below error is coming:
Below is implementation. Please advise how we can know the source of exception. When error is recceived (as per picture) control is not passed in below funtion. But when we remove below implemention error stops coming .
So here are our thoughts:
Broadcast receiver class
class MySMSBroadcastReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
try {
if (intent != null && SmsRetriever.SMS_RETRIEVED_ACTION == intent.action && intent.extras != null ) {
val extras = intent.extras
val status : Status? = extras?.get(SmsRetriever.EXTRA_STATUS) as Status?
unregister(receiver)
if (status != null) {
when (status.statusCode) {
CommonStatusCodes.SUCCESS -> {
sms = extras?.getString(SmsRetriever.EXTRA_SMS_MESSAGE) as String
ignoreIllegalState {
val regex = Regex("\\b\\d{4,6}\\b")
val matches = regex.findAll(sms!!)
val result = matches.map { it.value }.toList()
pendingResult?.success(result[0])
}
}
CommonStatusCodes.TIMEOUT -> {
Log.e(Tag, "onReceive Timeout ")
}
}
}
}
} catch (e : Exception) {
Log.e(Tag, "onReceive Exception ${e}")
}
}
}
Upvotes: 0
Views: 29