Flutter plugin that implements Android's SMS User Consent API

Overview

sms_user_consent

Request user's phone number (supports dual sim) and/or consent to read SMS without adding any permissions, using Android's SMS User Consent API

Screenshots

Steps to use

1] Create an instance, optionally supply phone number listener and sms listener

SmsUserConsent smsUserConsent = SmsUserConsent(
        // optionally, do something when user selects a number.
        // You can even add/update this listener later on by simply 
        // calling smsUserConsent.updatePhoneNumberListener(updatedListener)
        phoneNumberListener: () {},
        
        // optionally, do something when user receives sms.
        // You can even add/update this listener later on by simply 
        // calling smsUserConsent.updateSmsListener(updatedListener)
        smsListener: () {}
);

2a] OPTIONAL : Request user's phone number

smsUserConsent.requestPhoneNumber();

Once the user selects a phone number, it can be accessed as

smsUserConsent.selectedPhoneNumber;

2b] OPTIONAL : Request to receive SMS

smsUserConsent.requestSms(); 

or you can specify the phone number you wish to capture the SMS from

smsUserConsent.requestSms(senderPhoneNumber: sender_number);

Once the user receives a SMS and the user taps Allow, it can be accessed as

smsUserConsent.receivedSms;

3] Finally, dispose the instance

smsUserConsent.dispose();

Note

As per the SMS User Consent API, message will be received by the plugin only if it meets these criteria:

  • The message contains a 4-10 character alphanumeric string with at least one number.
  • The message was sent by a phone number that's not in the user's contacts.
  • If you specified the sender's phone number, the message was sent by that number.

Contributing

  • Found a bug or idea to improve the plugin? Send a PR.
  • Found this plugin helpful and want to thank me? I love
  • Want to hire me for a gig? Let's talk on LinkedIn

License

MIT © 2020 Harsh P

Comments
  • java.lang.IllegalArgumentException:  Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

    java.lang.IllegalArgumentException: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

    Tried the plugin with targetSdk set to 31. Upon smsUserConsent.requestPhoneNumber(), above exception is thrown.

    Please let know any workaround or update plugin with the fix. Thanks

    opened by timmid861 0
  • Update build.gradle

    Update build.gradle

    Following updates are necessary.

    • implementation 'com.google.android.gms:play-services-auth:20.2.0'
    • implementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1'

    I will update the method channel changes too.

    opened by mukundjogi 2
  • Playstore Policy violation and crash fixes

    Playstore Policy violation and crash fixes

    Updates: 🆕 Updated all the dependencies used for android framework. 🆕 Migrated flutter to latest version. 🐛 Added SEND_PERMISSION flag in register BroadcastReciever method. This will prevent google play policy violation. 🐛 Removed depreciated jcenter() and replaced with mavenCentral(). 🐛 Updated target SDK version. 🐛 Added try catch block for exception handling in onRecieve method. This will prevent app crashing.

    Note: The above changes are tested on production app and all changes are working as expected.

    opened by abdulrehmank7 4
  • Detect the broadcast intent is from SMS Retriever API by adding the SmsRetriever.SEND_PERMISSION permission to receiver.

    Detect the broadcast intent is from SMS Retriever API by adding the SmsRetriever.SEND_PERMISSION permission to receiver.

    opened by ctnataman 1
  • Crash brightness_1 Huawei Y9 Prime 2019 brightness_1 Android 10 (SDK 29) brightness_1

    Crash brightness_1 Huawei Y9 Prime 2019 brightness_1 Android 10 (SDK 29) brightness_1

    The plugin crashes on android 10. java.lang.RuntimeException: at android.app.ActivityThread.deliverResults (ActivityThread.java:5471) at android.app.ActivityThread.handleSendResult (ActivityThread.java:5512) at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:51) at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:149) at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:103) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2386) at android.os.Handler.dispatchMessage (Handler.java:107) at android.os.Looper.loop (Looper.java:213) at android.app.ActivityThread.main (ActivityThread.java:8178) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1101) Caused by: java.lang.IllegalArgumentException: at android.app.LoadedApk.forgetReceiverDispatcher (LoadedApk.java:1507) at android.app.ContextImpl.unregisterReceiver (ContextImpl.java:1647) at android.content.ContextWrapper.unregisterReceiver (ContextWrapper.java:664) at dev.pharsh.sms_user_consent.SmsUserConsentPlugin$onAttachedToActivity$1.onActivityResult (SmsUserConsentPlugin.kt:76) at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult (FlutterEnginePluginRegistry.java:691) at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult (FlutterEnginePluginRegistry.java:378) at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult (FlutterActivityAndFragmentDelegate.java:625) at io.flutter.embedding.android.FlutterActivity.onActivityResult (FlutterActivity.java:583) at android.app.Activity.dispatchActivityResult (Activity.java:8413) at android.app.ActivityThread.deliverResults (ActivityThread.java:5464)

    opened by david-macharia 4
Owner
null
A Flutter step_tracker plugin is collect information from user and display progress through a sequence of steps. this plugin also have privilege for fully customization from user side. like flipkart, amazon, myntra, meesho.

step_tracker plugin A Flutter step_tracker plugin is collect information from user and display progress through a sequence of steps. this plugin also

Roshan nahak 5 Oct 21, 2022
A flutter plugin that implements google's standalone ml kit

Google's ML Kit for Flutter Google's ML Kit for Flutter is a set of Flutter plugins that enable Flutter apps to use Google's standalone ML Kit. Featur

kyle reginaldo 2 Aug 29, 2022
Home app - A dynamic flutter app which can be used to generate alerts, set alarms and send sms or call someone

first_app A dynamic flutter app which can be used to generate alerts, set alarms

null 0 Apr 9, 2022
Flutter package for listening SMS code on Android, suggesting phone number, email, saving a credential.

Flutter Smart Auth From Tornike & Great Contributors Flutter package for listening SMS code on Android, suggesting phone number, email, saving a crede

Tornike 16 Jan 1, 2023
Flutter package for sending and verifying SMS/OTP

Flutter Termii A Flutter plugin that helps developers use messaging channels to verify and authenticate customer transactions Android iOS Linux macOS

Abdulazeez Oshinowo 5 May 26, 2022
SMS Receiver Channel For Android

SMS Receiver Channel SMS Receiver Channel For Android Getting Started Use channel on the client_side (flutter) and the platform_side (android) and inv

Niloofar Amerian 2 Nov 3, 2022
Implements GTK Widgets, themes and titlebar buttons in Flutter. Based on the GNOME HIG

GTK ❤️ Flutter Unofficial implementation of GTK Widgets, themes and titlebar buttons in Flutter. Based on the GNOME Human Interface Guidelines. Featur

Prateek SU 164 Dec 26, 2022
Implements Microsoft's Fluent Design System in Flutter.

fluent_ui Design beautiful native windows apps using Flutter Unofficial implementation of Fluent UI for Flutter. It's written based on the official do

Bruno D'Luka 1.8k Dec 29, 2022
This is an apps that implements fundamental features of Flutter (Android Apps Only)

rpl_apps_flutter A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Fakhry 0 Dec 28, 2021
Flutter package implements Sign Google redirect(working for incognito mode)

google_sign_in_web_redirect Flutter package implements Sign Google redirect(working for incognito mode). Usage Import the package dependencies: goog

null 2 Dec 15, 2022
Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flutter app.

Flutter Tutorial - User Profile Page UI 1/2 Create a Flutter User Profile Page UI where you can access and edit your user's information within your Fl

Johannes Milke 46 Dec 6, 2022
Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flutter app.

Flutter Tutorial - User Profile Page UI #2 Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flu

Johannes Milke 45 Dec 15, 2022
Let's create a complete Flutter User Profile Page with SharedPreferences to persist the user's information in Flutter.

Flutter Tutorial - User Profile & SharedPreferences Let's create a complete Flutter User Profile Page with SharedPreferences to persist the user's inf

Johannes Milke 21 Dec 3, 2022
User auth form - Signup and signin user auth form with ability to stay signed in and have an option to signout.

user_auth_form SIgnup and signin user authentification form Getting Started This project is a starting point for a Flutter application. A few resource

null 0 Jan 6, 2022
Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Gita Bhagavad Gita flutter app. Download App - Playstore Web Application About Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight No

Ravi Kovind 7 Apr 5, 2022
Beautiful Weather App using API with support for dark mode. Created by Jakub Sobański ( API ) and Martin Gogołowicz (UI, API help)

Flutter Weather App using API with darkmode support Flutter 2.8.1 Null Safety Beautiful Weather App using https://github.com/MonsieurZbanowanYY/Weathe

Jakub Sobański 5 Nov 29, 2022
Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.

Flutter permission_handler plugin The Flutter permission_handler plugin is build following the federated plugin architecture. A detailed explanation o

Baseflow 1.7k Dec 31, 2022
Unloc customizations of the Permission plugin for Flutter. This plugin provides an API to request and check permissions.

Flutter Permission handler Plugin A permissions plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check perm

Unloc 1 Nov 26, 2020