smart_auth 3.0.0-beta.1 copy "smart_auth: ^3.0.0-beta.1" to clipboard
smart_auth: ^3.0.0-beta.1 copied to clipboard

Wrapper of Android SMS User Consent API, SMS Retriever API to read one time sms code, get user phone number, OTP, OTC, sms autofill, android autofill

Flutter Smart Auth

Need anything Flutter related? Reach out on LinkedIn

Pub package GitHub starts style: effective dart pub package

Flutter package for listening SMS code on Android, suggesting phone number, email, saving a credential.

If you need pin code input like shown below, take a look at the Pinput package.

Features: #

  • Android Autofill
    • SMS Retriever API
    • SMS User Consent API
  • Showing Phone number hints API

Support #

Discord Channel

Example

Don't forget to give it a star ⭐

If you want to contribute to this project, please read the contribution guide.

Requirements #

1. Set kotlin version to 2.0.0 or above and gradle plugin version to 8.3.2

If you are using legacy imperative apply

// android/build.gradle
buildscript {
    ext.kotlin_version = '2.0.0'
    ...others

    dependencies {
        classpath 'com.android.tools.build:gradle:8.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

If you are using new declarative plugin approach

// android/settings.gradle
plugins {
    id "org.jetbrains.kotlin.android" version "2.0.0" apply false
    id "com.android.application" version "8.3.2" apply false
    ...others
}

2. Set gradle version to 8.4.0 or above - more about gradle versions

// android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip

3. Set Java version to 21

// android/app/build.gradle
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_21
    targetCompatibility = JavaVersion.VERSION_21
}

kotlinOptions {
    jvmTarget = JavaVersion.VERSION_21.toString()
}

Getting Started #

Create instance of SmartAuth #


final smartAuth = SmartAuth();

Get the App signature #

void getAppSignature() async {
  final res = await smartAuth.getAppSignature();
  debugPrint('Signature: $res');
}
void getSmsWithRetrieverApi() async {
  final res = await smartAuth.getSmsWithRetrieverApi();
  if (res.succeed) {
    debugPrint('SMS: ${res.code}');
  } else {
    debugPrint('SMS Failure:');
  }
}

Get SMS with SMS Retriever API #

void getSmsWithUserConsentApi() async {
  final res = await smartAuth.getSmsWithUserConsentApi();
  if (res.succeed) {
    debugPrint('SMS: ${res.code}');
  } else {
    debugPrint('SMS Failure:');
  }
}

The plugin automatically removes listeners after receiving the code, if not you can remove them by #

calling the removeUserConsentApiListener or removeSmsRetrieverApiListener methods

void removeSmsListener() {
  smartAuth.removeUserConsentApiListener();
  // or
  smartAuth.removeSmsRetrieverApiListener();
}

Request phone number hint #

void requestPhoneNumberHint() async {
  final res = await smartAuth.requestPhoneNumberHint();
  debugPrint('requestHint: $res');
}
122
likes
0
points
150k
downloads

Publisher

verified publisherfman.ge

Weekly Downloads

Wrapper of Android SMS User Consent API, SMS Retriever API to read one time sms code, get user phone number, OTP, OTC, sms autofill, android autofill

Repository (GitHub)
View/report issues

Topics

#otp #sms-autofill #sms-user-consent-api #sms-retriever-api #smart-lock

Funding

Consider supporting this project:

ko-fi.com

License

unknown (license)

Dependencies

flutter

More

Packages that depend on smart_auth