I want to implement OTP functionality in my android application. In this application, after signup user will receive one time password key. After verifying OTP, user will be able to register/open account successfully by using that OTP. What i need to do achieve this?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
I have implement a very simple method of OTP..
Check google authenticator. https://code.google.com/p/google-authenticator/ it is open source project with OTP functionality
Source code for android app https://code.google.com/p/google-authenticator/source/browse/?repo=android
Here is source code for server side https://github.com/chregu/GoogleAuthenticator.php
Wikipedia article http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm
As @Vipin mentioned, the best way would be implementing it your self:
First, you have to generate a 4-digit(or whatever you want) pin code, for example:
Then, you have to save this number somewhere save, for example in your preferences:
The next step, would be using a proper SMS gateway to send that OTP to the corresponding phone number, for me I'm using clickATell with our php server to send the message, the api documentation is pretty clear. And if you want to send the message directly from the application, may be SMSgateway can help.
The final step, is to verify the code received by SMS is the one stored in device preferences, this is pretty easy and straight forward, all you have to do is to provide an
EditText
for the user allowing him to enter the code received by his phone, if the code matches the OTP saved in device preferences, make him go through the app, otherwise, display a proper error message.a classy move: Not mandatory but preferably, as a lot of applications doing you can provide SMS listener to listen to the upcoming messages, getting the code from the received message, display it in the code verification
editText
, verify it, if true, go through the app.in manifest.xml:
the listener:
the receiver: