diff --git a/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt b/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt index 5f3f2d4..e533455 100644 --- a/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt +++ b/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt @@ -123,6 +123,7 @@ 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. } @@ -130,6 +131,7 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi val phoneNumber = Identity.getSignInClient(context!!).getPhoneNumberFromIntent(data) lastResult?.success(phoneNumber) + lastResult = null } } return true @@ -170,6 +172,7 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi override fun onFailure() { lastResult?.error("408", "Timeout exception", null) + lastResult = null } } } @@ -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 } } } diff --git a/example/android/build.gradle b/example/android/build.gradle index 83ae220..3cdaac9 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir }