Giter VIP home page Giter VIP logo

sms_user_consent's Introduction

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

sms_user_consent's People

Contributors

nico04 avatar pharshdev avatar san-smith avatar

Stargazers

 avatar

Forkers

sur950

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.