black friday sale

Flat 10% off on the purchase of any two apps or more. Use coupon code - FESTIVAL10

Grab It Now
Check Mobile App
Read now
Start a Project

Fetching OTP(one time password) from message

Save

All of us have seen a plenty of applications that use OTP for login process but pretty much of them access your message and fill the OTP in its place by itself and we just loved it because it saves our work and time. We don’t have to put our application in background and then note the OTP and come back or even go to notification bar to know the OTP. So basically this feature is quiet interesting. Today I will show you how you can implement this in your android application.

Firstly and for mostly we have to create a BroadcastReceiver which will process the message for us. So lets create a receiver named ReceiveMessage

As you can see onReceive we have extracted the message, you can add regular expressions to get the exact code your server is sending, and instantialtied our activity to call a method onRecieveOPT(String). So we are implementing our Activity and this method in it.

So we declared our activity as well as method. You can see here I had put the whole text as it is in EditText. But as I said you can apply a regular expression to extract only code. Also be sure to mention your receiver in manifest file with proper permissions.

And you are ready to receive your OTP directly in your application.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

Michael Urresta

Michael Urresta

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home