I'm trying to use Google's SMS Retriever API for Automatic SMS Verification, but there is an issue in it.
previously , I was reading sender number using getOriginatingAddress()
and if it's valid sender number then read OTP otherwise it should not read message. As , forwarded OTP is disturbing user's privacy.
I have the following scenario.
My app is auto-fetching forwarded OTP messages.
is there any way around to get sender number.?
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:
Automatic SMS verification can be done with the help of an API called the SMS Retriever API. With the use of this API, users do not need to enter the verification code manually nor does the API require any extra app permissions. In this tutorial, we’ll learn how we can implement this feature in an Android app.
The SMS retrieval task will listen for up to five minutes for an SMS message that contains a unique string that identifies your app. 3. Send the phone number to your server using any method (usually with an HTTPS POST request).
// Get an instance of SmsRetrieverClient, used to start listening for a matching // SMS message. SmsRetrieverClient client = SmsRetriever.getClient (this /* context */); // Starts SmsRetriever, which waits for ONE matching SMS message until timeout // (5 minutes).
There is no way for you to achieve sender verification by using SMS Retriever API.
There is a workaround to handle this scenario for this which would be at SMSC end. That would be that share the hashcode of your verification SMS with SMSC guys to not to forward or restrict SMS that contains that specific hashcode in SMS body. It's not a good approach but that's the only option with SMS Retriever API
Though there is another way which I will recommend
Google has released another API that deals with sender verification but it has different flow then SMS Retriever API and Its called SMS User Consent API This API has following criteria for a message to be delivered and auto fetch by device
A message triggers the broadcast only if it meets these criteria:
Hope this will help you!
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