Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: possible crash #57

Merged
merged 11 commits into from
Jul 12, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi
// Get SMS message content
val message = data.getStringExtra(SmsRetriever.EXTRA_SMS_MESSAGE)
lastResult?.success(message)
lastResult = null
} else {
// Consent denied. User can type OTC manually.
}
credentialPickerRequest -> if (resultCode == Activity.RESULT_OK && data != null) {
val phoneNumber =
Identity.getSignInClient(context!!).getPhoneNumberFromIntent(data)
lastResult?.success(phoneNumber)
lastResult = null
}
}
return true
Expand Down Expand Up @@ -170,6 +172,7 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi

override fun onFailure() {
lastResult?.error("408", "Timeout exception", null)
lastResult = null
}
}
}
Expand All @@ -182,11 +185,15 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi
smsRetrieverBroadcastReceiver = SmsRetrieverReceiver().also {
it.smsBroadcastReceiverListener = object : SmsRetrieverReceiver.SmsRetrieverBroadcastReceiverListener {
override fun onSuccess(sms: String?) {
sms?.let { it -> lastResult?.success(it) }
sms?.let { it ->
lastResult?.success(it)
lastResult = null
}
}

override fun onFailure() {
lastResult?.error("408", "Timeout exception", null)
lastResult = null
}
}
}
Expand Down