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

The Flutter package provides seamless integration of the SMS Retriever API for automatic SMS verification on the Android platform. This package allows your Android application to automatically read OT [...]

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 #

Please add this Signature Code at the end of the OTP SMS.

var appSignature = await AutoSmsVerification.appSignature();  

Add Widget #

Listen for SMS; it will return the SMS text, which you can then use to extract the OTP.

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

Call function in initState

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

Ensure to stop listening for SMS in the dispose function to prevent memory leaks and unnecessary background processes.

@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  
9
likes
0
points
43
downloads

Publisher

unverified uploader

Weekly Downloads

The Flutter package provides seamless integration of the SMS Retriever API for automatic SMS verification on the Android platform. This package allows your Android application to automatically read OTPs (One-Time Passwords) without requiring manual user input, enhancing the user experience by streamlining the verification process. With this package, you can ensure secure and efficient OTP handling directly within your Flutter application.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on auto_sms_verification

Packages that implement auto_sms_verification