An AutoFillOTP
component will help you to enable a listener. The listner will wait for the SMS
in your phone
to enable autoFillOTP.
Note: SMS
should follow the format. To use auto fill OTP, last line of the sms should contain
@your-domain.com #12345
A minimal Demo Link
Value | Used as a | Description |
---|---|---|
AutoFillOtp | ✅ Component | Can be used as Component |
autoFillOtp | ✅ Service | Can be used as Service |
// Default import will return AutoFillOtp Component
import AutoFillOtp from 'fe-pilot/AutoFillOtp';
<AutoFillOtp /> // Used as a Component
import { AutoFillOtp, autoFillOtp } from 'fe-pilot/AutoFillOtp'; // Multi Export
<AutoFillOtp /> // Used as a Component
autoFillOtp(); // Used as a Service
import { autoFillOtp } from 'fe-pilot/AutoFillOtp';
const successCb = (response) => {
console.log("success response:", response);
}
const failureCb = (response) => {
console.log("failure response:", response);
}
autoFillOtp({
successCb
failureCb
});
Important
To work AutoFillOtp successfully, your otp message template should follow the below format.
Your OTP is 123456
@your-domain.com #123456
Props | Type | Description | Response |
---|---|---|---|
successCb | Function | It will be called on success |
{ data: "Can be array/object/string/number", msgType: "SUCCESSFUL", msg: "A success msg", status: "SUCCESS" } |
loadingCb | Function | It will be called before success/failure. |
{ msgType: "LOADING", msg: "LOADING...", status: "LOADING" } |
failureCb | Function | It will be called on failure |
{ msgType: "ERROR", msg: "A failed msg", status: "FAILURE" } |
Props | Type | Description | Default Values |
showForever | Boolean | To hide/remove unsupported feature, make it false. | Default value is true. |