1. Go to this page and download the library: Download vipertecpro/otp-autofill library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vipertecpro / otp-autofill example snippets
use Native\Mobile\Attributes\On;
use Native\Mobile\Edge\NativeComponent;
use Vipertecpro\OtpAutofill\Events\OtpFailed;
use Vipertecpro\OtpAutofill\Events\OtpReceived;
use Vipertecpro\OtpAutofill\Facades\OtpAutofill;
class VerifyPhone extends NativeComponent
{
public string $code = '';
public string $error = '';
public function sendCode(): void
{
Http::post(config('services.api.url').'/verify/send', ['phone' => $this->phone]);
OtpAutofill::start(['length' => 6]); // Android starts listening; iOS: "keyboard"
}
#[On(OtpReceived::class)]
public function onCode(string $code): void
{
$this->code = $code; // fills the boxes
$this->verify($code);
}
#[On(OtpFailed::class)]
public function onFailed(string $reason): void
{
$this->error = $reason === 'denied' ? '' : 'Type the code from the SMS.';
}
public function verify(string $code): void
{
// check it with your API
}
}