I am trying to implement SMS Retriever API, but I am unable to find classes like SmsRetrieverClient
. I'm not able to import them.
Refer to the following sample code:
SmsRetrieverClient client = SmsRetriever.getClient(context);
Task<Void> task = client.startSmsRetriever();
task.addOnSuccessListener(new OnSuccessListener<Void>() {});
I have added following dependency, after which I am able to refer the classes:
compile 'com.google.android.gms:play-services:11.0.2'
But as this include all service API, I want to know the dependency specific to SMS Retriever API
I have referred to this doc for all dependency and added following, but it did not work.
com.google.android.gms:play-services-auth:11.0.2
com.google.android.gms:play-services-identity:11.0.2
Also, is it necessary to have 11.x.x versions?
Google Play services has two APIs you can use to streamline the SMS-based verification process: the SMS Retriever API and the SMS User Consent API. The SMS Retriever API provides a fully automated user experience and should be used when possible.
With the SMS Retriever API, you can perform SMS-based user verification in your Android app automatically, without requiring the user to manually type verification codes, and without requiring any extra app permissions. When you implement automatic SMS verification in your app, the verification flow looks like this:
With the SMS Retriever API, we can perform SMS-based user verification in our Android app automatically, without requiring the user to manually type verification codes, and without requiring any extra app permissions In this article, we will learn our SMS Retriever API and see how this can be easily used for SMS verification. So, let’s get started.
After obtaining phone number and started SMS retriever, you need to send the user’s phone number to your verification sever using any method. register receiver in AndroidManifest.xml with intent filter com.google.android.gms.auth.api.phone.SMS_RETRIEVED
Try adding the following dependency:
implementation "com.google.android.gms:play-services-auth-api-phone:$playServicesVersion"
replace $playServicesVersion
with the play services version you are using.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With