{"id":24614647,"url":"https://github.com/tkko/flutter_smart_auth","last_synced_at":"2025-04-04T20:09:43.130Z","repository":{"id":42533903,"uuid":"470926545","full_name":"Tkko/flutter_smart_auth","owner":"Tkko","description":"Flutter package for listening SMS code on Android, suggesting phone number, email, saving a credential.","archived":false,"fork":false,"pushed_at":"2025-01-01T13:00:00.000Z","size":671,"stargazers_count":58,"open_issues_count":7,"forks_count":31,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T19:07:21.279Z","etag":null,"topics":["androidautofill","flutter","flutterpackage","pin","pin-input","sms-code","sms-verification","smsretrieverapi","smsuserconsentapi","smsverify"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/smart_auth","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tkko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-17T09:26:48.000Z","updated_at":"2025-02-26T20:13:14.000Z","dependencies_parsed_at":"2024-06-19T01:48:15.506Z","dependency_job_id":"fff45be0-99d6-4a66-94c9-5b25898d436e","html_url":"https://github.com/Tkko/flutter_smart_auth","commit_stats":{"total_commits":66,"total_committers":8,"mean_commits":8.25,"dds":0.5606060606060606,"last_synced_commit":"be97b1bcfb3169d90ab5792393afea574d964630"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tkko%2Fflutter_smart_auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tkko%2Fflutter_smart_auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tkko%2Fflutter_smart_auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tkko%2Fflutter_smart_auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tkko","download_url":"https://codeload.github.com/Tkko/flutter_smart_auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242678,"owners_count":20907134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["androidautofill","flutter","flutterpackage","pin","pin-input","sms-code","sms-verification","smsretrieverapi","smsuserconsentapi","smsverify"],"created_at":"2025-01-24T21:17:47.838Z","updated_at":"2025-04-04T20:09:43.112Z","avatar_url":"https://github.com/Tkko.png","language":"Kotlin","readme":"\u003cdiv align=\"center\"\u003e\n \u003ch1 align=\"center\" style=\"font-size: 70px;\"\u003eFlutter Smart Auth\u003c/h1\u003e\n\n\u003c!--  Donations --\u003e\n \u003ca href=\"https://ko-fi.com/flutterman\"\u003e\n  \u003cimg width=\"300\" src=\"https://user-images.githubusercontent.com/26390946/161375567-9e14cd0e-1675-4896-a576-a449b0bcd293.png\"\u003e\n \u003c/a\u003e\n \u003cdiv align=\"center\"\u003e\n   \u003ca href=\"https://www.buymeacoffee.com/fman\"\u003e\n    \u003cimg width=\"150\" alt=\"buymeacoffee\" src=\"https://user-images.githubusercontent.com/26390946/161375563-69c634fd-89d2-45ac-addd-931b03996b34.png\"\u003e\n  \u003c/a\u003e\n   \u003ca href=\"https://ko-fi.com/flutterman\"\u003e\n    \u003cimg width=\"150\" alt=\"Ko-fi\" src=\"https://user-images.githubusercontent.com/26390946/161375565-e7d64410-bbcf-4a28-896b-7514e106478e.png\"\u003e\n  \u003c/a\u003e\n \u003c/div\u003e\n\u003c!--  Donations --\u003e\n\n\u003ch3 align=\"center\" style=\"font-size: 35px;\"\u003eNeed anything Flutter related? Reach out\non \u003ca href=\"https://www.linkedin.com/in/thornike/\"\u003eLinkedIn\u003c/a\u003e\n\u003c/h3\u003e\n\n[![Pub package](https://img.shields.io/pub/v/smart_auth.svg)](https://pub.dev/packages/smart_auth)\n[![GitHub starts](https://img.shields.io/github/stars/tkko/flutter_smart_auth.svg?style=flat\u0026logo=github\u0026colorB=deeppink\u0026label=stars)](https://github.com/tkko/flutter_smart_auth)\n[![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)\n[![pub package](https://img.shields.io/badge/license-MIT-purple.svg)](https://opensource.org/licenses/MIT)\n\n\u003c/div\u003e\n\n\nFlutter package for listening SMS code on Android, suggesting phone number, email, saving a\ncredential.\n\n_If you need pin code input like shown below, take a look at\nthe [Pinput](https://github.com/Tkko/Flutter_Pinput) package._\n\n\u003cimg src=\"https://user-images.githubusercontent.com/26390946/155599527-fe934f2c-5124-4754-bbf6-bb97d55a77c0.gif\" width=\"160px\"/\u003e\n\n## Features:\n\n- Android SMS Autofill\n    - SMS Retriever [API](https://developers.google.com/identity/sms-retriever/overview?hl=en)\n    - SMS User\n      Consent [API](https://developers.google.com/identity/sms-retriever/user-consent/overview)\n- Showing Phone number\n  hints [API](https://developers.google.com/identity/android-credential-manager)\n\n## Support\n\nDiscord [Channel](https://rebrand.ly/qwc3s0d)\n\n[Example](https://github.com/Tkko/flutter_smart_auth/blob/main/example/lib/main.dart)\n\nDon't forget to give it a star ⭐\n\nIf you want to contribute to this project, please read the [contribution](CONTRIBUTING.md) guide.\n\n## Requirements\n\n#### 1. Set kotlin version to 1.8.0 or above and gradle plugin version to 8.3.2\n\nIf you are\nusing [legacy imperative apply](https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply)\n\n```\n// android/build.gradle\nbuildscript {\n    ext.kotlin_version = '1.8.0'\n    ...others\n\n    dependencies {\n        classpath 'com.android.tools.build:gradle:8.3.2'\n        classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"\n    }\n}\n```\n\nIf you are using\nnew [declarative plugin approach](https://docs.gradle.org/8.5/userguide/plugins.html#sec:plugins_block)\n\n```\n// android/settings.gradle\nplugins {\n    id \"org.jetbrains.kotlin.android\" version \"1.8.0\" apply false\n    id \"com.android.application\" version \"8.3.2\" apply false\n    ...others\n}\n```\n\n#### 2. Set gradle version to 8.4.0 or above - [more about gradle versions](https://developer.android.com/build/releases/gradle-plugin)\n\n```\n// android/gradle/wrapper/gradle-wrapper.properties\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-8.4-all.zip\n```\n\n#### 3. Set Java version to 11\n\n```\n// android/app/build.gradle\ncompileOptions {\n    sourceCompatibility = JavaVersion.VERSION_11\n    targetCompatibility = JavaVersion.VERSION_11\n}\n\nkotlinOptions {\n    jvmTarget = '11'\n}\n```\n\n## Getting Started\n\n### Create instance of SmartAuth\n\n```dart\n\nfinal smartAuth = SmartAuth.instance;\n```\n\n### Request phone number hint - [Docs](https://developers.google.com/identity/phone-number-hint/android)\n\nThe Phone Number Hint API, a library powered by Google Play services, provides a frictionless way to\nshow a user’s (SIM-based) phone numbers as a hint.\n\nThe benefits to using Phone Number Hint include the following:\n\n- No additional permission requests are needed\n- Eliminates the need for the user to manually type in the phone number\n- No Google account is needed\n- Not directly tied to sign in/up workflows\n- Wider support for Android versions compared to Autofill\n\n```dart\nvoid requestPhoneNumberHint() async {\n  final res = await smartAuth.requestPhoneNumberHint();\n  if (res.hasData) {\n    // Use the phone number\n  } else {\n    // Handle error\n  }\n}\n```\n\n\u003cimg src=\"https://github.com/user-attachments/assets/efff8893-4ac4-4601-98b5-1fb10ae365a3\" width=\"250px\"/\u003e\n\n### Get SMS with User Consent [API](https://developers.google.com/identity/sms-retriever/user-consent/overview)\n\nThe SMS User Consent API complements the SMS Retriever API by allowing an app to prompt the user to\ngrant access to the content of a single SMS message. When a user gives consent, the app will then\nhave access to the entire message body to automatically complete SMS verification. The verification\nflow looks like this:\n\n1. A user initiates SMS verification in your app. Your app might prompt the user to provide a phone\n   number manually or request the phone number hint by calling `requestPhoneNumberHint` method.\n2. Your app makes a request to your server to verify the user's phone number. Depending on what\n   information is available in your user database, this request might include the user's ID, the\n   user's phone number, or both.\n3. At the same time, your app calls the `getSmsWithUserConsentApi` to show the user a dialog to\n   grant access to the SMS message.\n4. Your server sends an SMS message to the user that includes a one-time code to be sent back to\n   your server.\n5. When the user's device receives the SMS message, the `getSmsWithUserConsentApi` will extract the\n   one-time code from the message text and you have to send it back to your server.\n7. Your server receives the one-time code from your app, verifies the code, and finally records that\n   the user has successfully verified their account.\n\n```dart\nvoid getSmsWithUserConsentApi() async {\n  final res = await smartAuth.getSmsWithUserConsentApi();\n  if (res.hasData) {\n    final code = res.requireData.code;\n\n    /// The code can be null if the SMS was received but the code was not extracted from it\n    if (code == null) return;\n    //  Use the code\n  } else if (res.isCanceled) {\n    // User canceled the dialog\n  } else {\n    // handle the error\n  }\n}\n```\n\n\u003cimg src=\"https://github.com/user-attachments/assets/60ace6bc-6c28-43cf-ae1d-60f56aaae8d2\" width=\"250px\"/\u003e\n\n### Get SMS with SMS Retriever [API](https://developers.google.com/identity/sms-retriever/overview?hl=en)\n\nWith the SMS Retriever API, you can perform SMS-based user verification in your Android app\nautomatically, without requiring the user to manually type verification codes, and without requiring\nany extra app permissions. When you implement automatic SMS verification in your app, the\nverification flow looks like this:\n\n\u003cimg src=\"https://github.com/user-attachments/assets/7daa8895-14d4-460f-b9e7-4710446788d3\"/\u003e\n\n1. A user initiates SMS verification in your app. Your app might prompt the user to provide a phone\n   number manually or request the phone number hint by calling `requestPhoneNumberHint` method.\n2. Your app makes a request to your server to verify the user's phone number. Depending on what\n   information is available in your user database, this request might include the user's ID, the\n   user's phone number, or both.\n3. At the same time, your app calls the `getSmsWithRetrieverApi` to begin listening for an SMS\n   response from your server.\n4. Your server sends an SMS message to the user that includes a one-time code to be sent back to\n   your server, and a hash that identifies your app.\n5. When the user's device receives the SMS message, Google Play services uses the app hash to\n   determine that the message is intended for your app, and makes the message text available to your\n   app through the SMS Retriever API.\n6. The `getSmsWithRetrieverApi` will extract the one-time code from the message text and you have to\n   send it back to your server.\n7. Your server receives the one-time code from your app, verifies the code, and finally records that\n   the user has successfully verified their account.\n\n```dart\nvoid getSmsWithRetrieverApi() async {\n  final res = await smartAuth.getSmsWithRetrieverApi();\n  if (res.hasData) {\n    final code = res.requireData.code;\n\n    /// The code can be null if the SMS was received but the code was not extracted from it\n    if (code == null) return;\n    //  Use the code\n  } else {\n    // handle the error\n  }\n}\n```\n\n### Dispose\n\nThe plugin automatically removes listeners after receiving the code, if not you can remove them by\ncalling the `removeUserConsentApiListener` or `removeSmsRetrieverApiListener` method.\n\n```dart\nvoid removeSmsListener() {\n  smartAuth.removeUserConsentApiListener();\n  // or\n  smartAuth.removeSmsRetrieverApiListener();\n}\n```\n","funding_links":["https://ko-fi.com/flutterman","https://www.buymeacoffee.com/fman"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkko%2Fflutter_smart_auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftkko%2Fflutter_smart_auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkko%2Fflutter_smart_auth/lists"}