Skip to content

Instantly share code, notes, and snippets.

@TobiAlbert
Created June 20, 2020 04:05
Show Gist options
  • Select an option

  • Save TobiAlbert/4369a878df2cbaa899fdd24837292a2f to your computer and use it in GitHub Desktop.

Select an option

Save TobiAlbert/4369a878df2cbaa899fdd24837292a2f to your computer and use it in GitHub Desktop.
val task = SmsRetriever.getClient(this).startSmsUserConsent(null)
task.addOnCompleteListener {
task?.exception?.let {
// handle possible exception
Log.e(TAG, "Task Exception: $it")
return@addOnCompleteListener
}
if (task.isSuccessful) {
val intentFilter = IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION)
registerReceiver(smsBroadcastReceiver, intentFilter, SmsRetriever.SEND_PERMISSION, null)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment