パッケージ、リポジトリ、アプリカテゴリを検索

sms_autofill のカバー
パッケージ詳細v2.6.1

sms_autofill

SMS コードのオートフィル機能を提供する Flutter プラグイン

AndroidiOS
30日間ダウンロード
20.7万
いいね数
881
Pub ポイント
140

パッケージをインストール

flutter pub add sms_autofill

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

sms_autofill パッケージは、Android および iOS で SMS 認証コードの自動検出と自動入力を行うための Flutter プラグインです。SMS で送信された一時的なパスワード(OTP)を自動的に抽出することで、認証フロー中のユーザー体験を簡素化し、手動入力エラーを減らし、コンバージョン率を向上させます。このプラグインは、OTP 入力用に設計されたテキストフィールドとシームレスに統合され、プラットフォーム固有の API を活用して受信メッセージを検出し、プログラム的にフィールドを埋めます。

用途

  • ログインフローにおける自動OTP入力
  • アカウント認証におけるユーザーの摩擦を軽減する
  • フォームの完了率向上
  • 二要素認証をサポートしています
  • SMSコードによる迅速な登録を有効にする

主な機能

  • 自動SMSコード検出
  • クロスプラットフォーム対応(AndroidおよびiOS)
  • TextFormField とのシームレスな統合
  • 最小限のセットアップが必要
  • 受信メッセージからのリアルタイムコード抽出

適している対象

  • OTP入力を必要とする認証画面
  • SMSベースの2FAを持つアプリ
  • 電話認証付きのユーザーオンボーディングフロー
  • PIN/OTPフィールドのUXを向上させたい開発者
  • フォームの離脱を減らすことを目指すプロジェクト

注意事項

  • 検出のためには適切なSMSメッセージフォーマットが必要です
  • すべてのデバイスやキャリアで動作しない可能性があります
  • どのメッセージが自動入力されるかの制御が限定されている
  • プラットフォームレベルのSMS権限に依存します
  • すべてのエミュレータ環境で動作することを保証できません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

sms_autofill

pub package Flutter plugin to provide SMS code autofill support.

For iOS, this package is not needed as the SMS autofill is provided by default, but not for Android, that's where this package is useful.

No permission to read SMS messages is asked to the user as there no need thanks to SMSRetriever API.

Usage

You have two widgets at your disposable for autofill an SMS code, PinFieldAutoFill and TextFieldPinAutoFill.

Just before you sent your phone number to the backend, you need to let the plugin know that it needs to listen for the SMS with the code.

To do that you need to do:

await SmsAutoFill().listenForCode();

This will listen for the SMS with the code during 5 minutes and when received, autofill the following widget.

PinFieldAutoFill

PinFieldAutoFill

PinFieldAutoFill(
                decoration: // UnderlineDecoration, BoxLooseDecoration or BoxTightDecoration see https://github.com/TinoGuo/pin_input_text_field for more info,
                currentCode: // prefill with a code
                onCodeSubmitted: //code submitted callback
                onCodeChanged: //code changed callback
                codeLength: //code length, default 6
              ),
TextFieldPinAutoFill

TextFieldPinAutoFill

TextFieldPinAutoFill(
                decoration: // basic InputDecoration
                currentCode: // prefill with a code
                onCodeSubmitted: //code submitted callback
                onCodeChanged: //code changed callback
                codeLength: //code length, default 6
              ),
Android SMS constraint

For the code to be receive, it need to follow some rules as describe here: https://developers.google.com/identity/sms-retriever/verify

  • Be no longer than 140 bytes
  • Contain a one-time code that the client sends back to your server to complete the verification flow
  • End with an 11-character hash string that identifies your app

One example of SMS would be:

ExampleApp: Your code is 123456
FA+9qCX9VSu

Helper

PhoneFieldHint [Android only]

PhoneFieldHint is a widget that will allow you ask for system phone number and autofill the widget if a phone is choosen by the user.

Phone hint

Custom CodeAutoFill

If you want to create a custom widget that will autofill with the sms code, you can use the CodeAutoFill mixin that will offer you:

  • listenForCode() to listen for the SMS code from the native plugin when SMS is received, need to be called on your initState.
  • cancel() to dispose the subscription of the SMS code from the native plugin, need to be called on your dispose.
  • codeUpdated() called when the code is received, you can access the value with the field code.
  • unregisterListener() to unregister the broadcast receiver, need to be called on your dispose.
App Signature

To get the app signature at runtime just call the getter getAppSignature on SmsAutoFill. You can also find the sample code in example app.

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

このパッケージを使用しているプロジェクト