sms_consent_for_otp_autofill 1.0.0 copy "sms_consent_for_otp_autofill: ^1.0.0" to clipboard
sms_consent_for_otp_autofill: ^1.0.0 copied to clipboard

Flutter plugin to provide SMS User Consent API gives the content of a single SMS message to us if the user gives permission. this package will only provide otp instead of full message body.

sms_consent_for_otp_autofill #

Flutter plugin for otp auto fill, used SMS Consent API to provide the otp of a single SMS message to us if the user gives permission. For Android, that's where this package is useful. No need for iOS, 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, otp will be received by the plugin only if it meets these criteria:

  • The message contains 6-10 numbers.
  • 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.
  • my portfolio Portfolio
  • Want to hire me for a gig? Let's talk on LinkedIn
7
likes
0
points
222
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin to provide SMS User Consent API gives the content of a single SMS message to us if the user gives permission. this package will only provide otp instead of full message body.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on sms_consent_for_otp_autofill