auto_sms_verification 0.0.4 copy "auto_sms_verification: ^0.0.4" to clipboard
auto_sms_verification: ^0.0.4 copied to clipboard

PlatformAndroid

Read OTP in Android.

auto_sms_verification #

With the auto_sms_verification plugin, you can perform SMS-based user verification in your Android app automatically, without requiring the user to manually type verification codes, and without requiring any extra app permissions.

Please check the original doc as well https://developers.google.com/identity/sms-retriever/overview

Getting Started #

Import package #

import 'package:auto_sms_verification/auto_sms_verification.dart';

Get Signature Code #

var appSignature = await AutoSmsVerification.appSignature();

Add Widget #

listen SMS

void _startListeningOtpCode() async {
    var sms = await AutoSmsVerification.startListeningSms();
    _smsCode = getCode(sms) ?? '';
}

Call function in initState

@override
void initState() {
    super.initState();
    _startListeningOtpCode();
}

Stop Listening on dispose function

@override
  void dispose() {
    AutoSmsVerification.stopListening();
    super.dispose();
  }

Parse OTP from SMS #

String? getCode(String? sms) {
    if (sms != null) {
      final intRegex = RegExp(r'\d+', multiLine: true);
      final code = intRegex.allMatches(sms).first.group(0);
      return code;
    }
    return null;
}

Example Sms #

<#> MyApp: your one time code is 5664
fr4edrDVWsr
6
likes
110
pub points
65%
popularity

Publisher

unverified uploader

Read OTP in Android.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on auto_sms_verification