Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OTP/SMS auto fetch issue using SMS Retriever API Android

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.

  •  User A installs app on his mobile and enters User B mobile number.
  •  User B receives OTP and forwards it to User A.
  • App reads OTP on User A mobile and goes to home screen.

is there any way around to get sender number.?

like image 749
Atif AbbAsi Avatar asked Mar 18 '19 07:03

Atif AbbAsi


People also ask

What is the SMS Retriever API?

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:

How to implement automatic SMS verification in an Android app?

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.

How does the SMS retrieval task work?

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).

How to start smsretrieverclient listening for matching SMS messages?

// 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).


1 Answers

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:

  1. The message contains a 4-10 character alphanumeric string with at least one number.
  2. The message was sent by a phone number that's not in the user's contacts.
  3. If you specified the sender's phone number, the message was sent by that number.

Hope this will help you!

like image 153
Zeeshan Shabbir Avatar answered Oct 17 '22 22:10

Zeeshan Shabbir