패키지, 저장소 및 앱 카테고리 검색

패키지 상세v4.1.0

otp_autofill

사용자 동의 API 및 검색기 API를 사용한 OTP 자동 완성의 Android 구현. 다른 입력에서 OTP 코드를 수신할 수 있도록 추가.

AndroidiOS
30일 다운로드
2.9만
좋아요
293
Pub 점수
150

패키지 설치

flutter pub add otp_autofill

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

otp_autofill 패키지는 사용자 동의 API 및 리트리버 API를 사용하여 Android에서 OTP 자동 채우기를 가능하게 하며, SMS에서 일회용 비밀번호를 자동으로 감지하고 채울 수 있습니다. 이 패키지는 대체 입력 소스로부터 OTP 코드를 수신하는 것을 지원하여 인증 중 사용자 경험을 향상시킵니다. iOS에서도 작동하여 PIN 및 OTP 필드에 대한 크로스플랫폼 호환성을 제공합니다. 폼 입력과의 원활한 통합을 위해 설계되어 수동 입력 오류를 줄이고 로그인 프로세스를 빠르게 합니다.

사용 사례

  • 로그인 폼에서의 자동 OTP 감지
  • 이중 인증 중 사용자 경험 향상
  • SMS 기반 인증 흐름 지원
  • 기존 PIN 또는 암호 입력 필드와의 통합
  • 보조 소스에서 백업 OTP 검색 활성화

주요 기능

  • Android의 사용자 동의 및 검색기 API를 사용합니다
  • 크로스 플랫폼 지원 (Android 및 iOS)
  • SMS에서 OTP 코드 자동 추출
  • OTP 검색을 위한 백업 입력 방법
  • 텍스트 필드와의 간단한 통합

적합한 대상

  • 안전한 OTP 입력이 필요한 앱
  • SMS 인증을 사용한 인증 흐름
  • 사용자 혼란을 줄이려는 개발자
  • Android 및 iOS 플랫폼을 대상으로 한 프로젝트
  • PIN/OTP 필드를 포함한 폼 중심 애플리케이션

고려 사항

  • 완전한 기능을 위해서는 Android SDK 28 이상이 필요합니다
  • 추가 설정 없이 Android SMS 자동 채우기에 제한됨
  • iOS 구현은 시스템 수준의 OTP 처리에 의존합니다
  • 안드로이드에서 SMS 액세스에 필요한 권한
  • 다른 기기 제조업체 간에 테스트가 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

OTP autofill

Made by Surf 🏄‍♂️🏄‍♂️🏄‍♂️

Build Status Coverage Status Pub Version Pub Likes Pub popularity Flutter Platform

Overview

This plugin uses the SMS User Consent API and SMS Retriever API on Android.

You could use autofill from another input by using the OTPStrategy (e.g. from push-notification).

For testing you could create a TestStrategy.

iOS

On iOS, the OTP autofill feature is integrated into the TextField component. The code received from an SMS is stored for a duration of 3 minutes.

Rules for sms
  1. Sms must contain the word code or its translation in iOS supported localizations.
  2. The sms should contain only one sequence of digits.
iOS Testing

The iOS platform is capable of receiving OTP from any phone number, not just a specific sender.

Android

  • OTPInteractor.hint - displays a system dialog that allows the user to select from their saved phone numbers (recommendation from Google).
  • OTPInteractor.getAppSignature - creates the hash code of your application, which is used in the SMS Retriever API.
  • OTPInteractor.startListenUserConsent - the broadcast receiver that starts listening for OTP codes using the SMS User Consent API. It listens for a duration of 5 minutes, after which a timeout exception occurs.
  • OTPInteractor.startListenRetriever - the broadcast receiver that starts listening for OTP codes using the SMS Retriever API. It listens for a duration of 5 minutes, after which a timeout exception occurs.
  • OTPInteractor.stopListenForCode - used in dispose.

The plugin is designed to receive the full text of an SMS message and requires a parser to extract the relevant information from the message.

If you use the SMS User Consent API, the system will prompt the user for permission to access and read incoming messages.

Rules for SMS when using SMS User Consent API
  1. The message should contain an alphanumeric string of 4 to 10 characters, with at least one digit.
  2. The message was sent from a phone number that is not in the user's contacts.
  3. If the sender's phone number is specified, the message must originate from that number.
Rules for SMS when using SMS Retriever API
  1. The length should not exceed 140 bytes.
  2. It should contain a one-time code that the client sends back to your server to complete the verification process.
  3. It should include an 11-character hash string that identifies your app (refer to the documentation for server for more details). For testing, you can obtain it from OTPInteractor.getAppSignature.
Android Testing

The OTPInteractor.startListenForCode method allows the application to start receiving verification codes from a specific phone number, specified by the senderPhone argument.

You also can use Android Emulator to test the plugin. To do this, you need to send an SMS to the emulator with the following command:

adb emu sms send <senderPhone> <message>

E.g.:

adb emu sms send 900 "Your code is 12345. Do not share it with anyone."

Make sure senderPhone is the same as the one you specified in the startListenForCode method.

Usage

You should use OTPInteractor to interact with OTP.

To simplify implementation, consider using the OTPTextEditController as a controller for your TextField.

OTPTextEditController.startListenUserConsent - uses the SMS User Consent API and listens to user strategies. OTPTextEditController.startListenRetriever - uses the SMS Retriever API and listens to user strategies. OTPTextEditController.startListenOnlyStrategies - only listens to user strategies. OTPTextEditController.stopListen - used in dispose.

Installation

Add otp_autofill to your pubspec.yaml file:

dependencies:
  otp_autofill: $currentVersion$

At this moment, the current version of otp_autofill is otp_autofill version.

Android Installation

Set minSdkVersion at least to 19 in <project root>/android/app/build.gradle.

android {
  ...
  defaultConfig {
    ...
    minSdkVersion 19
    ...
  }
  ...
}

Example

  1. Create a simple strategy
class SampleStrategy extends OTPStrategy {
  @override
  Future<String> listenForCode() {
    return Future.delayed(
      const Duration(seconds: 4),
      () => 'Your code is 54321',
    );
  }
}
  1. Initialize and set the listener
late OTPTextEditController controller;
final scaffoldKey = GlobalKey();

@override
void initState() {
  super.initState();
  _otpInteractor = OTPInteractor();
  _otpInteractor.getAppSignature()
      .then((value) => print('signature - $value'));
  controller = OTPTextEditController(
    codeLength: 5,
    onCodeReceive: (code) => print('Your Application receive code - $code'),
  )..startListenUserConsent(
      (code) {
        final exp = RegExp(r'(\d{5})');
        return exp.stringMatch(code ?? '') ?? '';
      },
      strategies: [
        SampleStrategy(),
      ],
    );
}

Send new code

To receive a new code when a timeout exception occurs, you can pass a callback function to the onTimeOutException parameter and start listen for a new code.

controller = OTPTextEditController(
      codeLength: 5,
      onCodeReceive: (code) => print('Your Application receive code - $code'),
      otpInteractor: _otpInteractor,
      onTimeOutException: () {
        //TODO: start new listen to get new code
        controller.startListenUserConsent(
          (code) {
            final exp = RegExp(r'(\d{5})');
            return exp.stringMatch(code ?? '') ?? '';
          },
          strategies: [
            SampleStrategy(),
          ],
        );
      },
    )..startListenUserConsent(
        (code) {
          final exp = RegExp(r'(\d{5})');
          return exp.stringMatch(code ?? '') ?? '';
        },
        strategies: [
          TimeoutStrategy(),
        ],
      );

Changelog

All significant changes to this project will be documented in this file.

Issues

To report any issues, submit them directly in the Issues section.

Contribute

If you wish to contribute to the package (for instance, by enhancing the documentation, fixing a bug, or introducing a new feature), please review our contribution guide first and then submit your pull request.

Your PRs are always welcome.

How to reach us

Please don't hesitate to ask any questions about this package. Join our community chat on Telegram. We communicate in both English and Russian.

Telegram

License

Apache License, Version 2.0

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.