Auto Read SDK
The OTPLESS AutoRead SDK simplifies the process of automatically reading OTPs from SMS, WhatsApp ZeroTap or WhatsApp OneTap, enhancing the user experience in your Android applications.
Prerequisites
If you are already using OTPLESS SDK for authentication, then you don’t need to use AutoRead SDK because OTPLESS SDK auto reads the OTP itself. AutoRead SDK is to be used by merchants using OTPLESS APIs or some other vendor for authentication.
WhatsApp OTP AutoRead
- Get the OTP message template whitelisted by OTPLESS Support Team for OTPs that the users will receive on WhatsApp.
- Make sure the app hash that is whitelisted by OTPLESS matches your app hash at application runtime. If the app hash is different from the whitelisted app hash, WhatsApp OTP AutoRead won’t work. You can follow this guide to generate your app hash.
SMS OTP AutoRead
- Make sure that the SMS template contains your app hash. You can follow this guide to generate your app hash.
Dependency
Add the following dependency to your build.gradle
file:
How Auto Read Works
Auto Read uses a broadcast service to detect and capture OTPs. To enable this feature, you need to whitelist the OTP template with your App Hash and Package Name with WhatsApp/Meta or pass the app hash in SMS Template.
How to Whitelist the Template
Generate the App Hash
Use the OTPless utility function to get the App Hash.
import the following class
To get the application signature in base64 return String
and take first 11 characters
Send Details for Whitelisting
Send the following details to support@otpless.com from your registered email ID:
- App Hash
- Package Name
- App ID
Usage
To enable OTP AutoRead, use the following methods based on the type of OTP you want to auto-read:
SMS OTP AutoRead
Register for auto-reading OTPs from SMS by calling the registerSmsOtpReceiver
method:
WhatsApp ZeroTap OTP AutoRead
- WhatsApp ZeroTap OTP AutoRead works for devices with Android API level 24 (Nougat) and above.
Register for auto-reading OTPs from WhatsApp by calling the
registerWhatsAppZeroTap
method:
WhatsApp OneTap OTP AutoRead
- WhatsApp OneTap OTP AutoRead works for devices with Android API level 24 (Nougat) and above.
Register for auto-reading OTPs from WhatsApp by calling the
registerWhatsAppOneTap
method:
Additionally, ensure your activity is set to singleTop
launch mode and exported
attribute is true:
Override the onNewIntent
function to receive intent from WhatsApp for OneTap OTP AutoRead.
If you are using both SMS and WhatsApp OTP AutoRead methods, then unregister the SMS OTP receiver as well if OTP is fetched via WhatsApp.
Was this page helpful?