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