Skip to content

Commit

Permalink
fix: possible crash
Browse files Browse the repository at this point in the history
- unstable crash on second received code
- unstable crash on timeout
  • Loading branch information
tinted-knight committed Jul 6, 2023
1 parent 90a42b3 commit be3f7d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}

0 comments on commit be3f7d3

Please sign in to comment.