Reputation: 866
SmsRetrieverClient.startSmsUserConsent (senderPhoneNumber /* or null */)
This senderPhoneNumber is the number I know I will be receiving OTP from. My question is if I pass null, it can extract OTP from any number as documentation says (pass null so that it will consider any number would be allowed.). How will I know that my sender is correct? What happens if I receive two OTPs?
If this is not possible can I somehow pass two sender numbers that I am sure that either would be sending my OTP?
Anyone have any knowledge regarding this, please let know.
Upvotes: 2
Views: 1270
Reputation: 7220
I did my research and writing my answer with my best. Coming to your questions
- What happens if I receive two OTPs?
The answer to this question is you will not receive two messages in most of the cases which contain an OTP within a span of 5 minutes.
Even though let's consider a worse situation. Suppose you receive 2 SMS containing OTP back to back in that case SMS user consent API will only show the consent for the first received SMS (Assuming you have mentioned null
as sender phone number).
So basically what happens is the user consent api will stop listning for sms once it detects and show a consent.
- If this is not possible can I somehow pass two sender numbers that I am sure that either would be sending my OTP?
Answer : Yes you can. if you know the senders possible names i.e say AD-Something, BC-Something, CC-Something
then you can register the listners for all 3 of them one by one like this
val task1 = SmsRetriever.getClient(applicationContext).startSmsUserConsent("AD-Something")
val task2 = SmsRetriever.getClient(applicationContext).startSmsUserConsent("CC-Something")
val task3 = SmsRetriever.getClient(applicationContext).startSmsUserConsent("BC-Something")
once you declare like this your device will listen for all of those. Make sure you also check for a callback on these to know whether they are successful or not
How do I know these?
There is no official source/documentation for this. (I looked for the documentation but I didn't find any mentions regarding this) Then I tried it for myself and found it.
Honestly, I have a feeling like this question is just another version of pre-mature optimization at this time
Thank you.
Upvotes: 3