A Package that helps in verifying phone numbers and email addresses using Twilio.
To use this package :
- add the dependency to your pubspec.yaml file.
dependencies:
flutter:
sdk: flutter
twilio_phone_verify:
TwilioPhoneVerify _twilioPhoneVerify;
_twilioPhoneVerify = new TwilioPhoneVerify(
accountSid: '*************************', // replace with Account SID
authToken: 'xxxxxxxxxxxxxxxxxx', // replace with Auth Token
serviceSid: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' // replace with Service SID
);
var twilioResponse =
await _twilioPhoneVerify.sendSmsCode('phone');
if (twilioResponse.successful) {
//code sent
} else {
//print(twilioResponse.errorMessage);
}
var twilioResponse = await _twilioPhoneVerify.verifySmsCode(
phone: 'phone', code: 'code');
if (twilioResponse.successful) {
if (twilioResponse.verification.status == VerificationStatus.approved) {
//print('Phone number is approved');
} else {
//print('Invalid code');
}
} else {
//print(twilioResponse.errorMessage);
}
Twilio Verify email channel requires additional Service configuration. Please refer to the email channel setup documentation for detailed instructions.
var twilioResponse =
await _twilioPhoneVerify.sendEmailCode('email');
if (twilioResponse.successful) {
//code sent
} else {
//print(twilioResponse.errorMessage);
}
var twilioResponse = await _twilioPhoneVerify.verifyEmailCode(
email: 'email', code: 'code');
if (twilioResponse.successful) {
if (twilioResponse.verification.status == VerificationStatus.approved) {
//print('Email is approved');
} else {
//print('Invalid code');
}
} else {
//print(twilioResponse.errorMessage);
}
var twilioResponse =
await _twilioPhoneVerify.sendEmailCode('email',channelConfiguration:
EmailChannelConfiguration(
from: "[email protected]",
from_name: "Override Name",
template_id: "d-4f7abxxxxxxxxxxxx",
usernameSubstitution: "Foo Bar"
));
if (twilioResponse.successful) {
//code sent
} else {
//print(twilioResponse.errorMessage);
}
- Phone verification
- Email verification.
For help getting started with Flutter, view our online documentation.
For help on editing package code, view the documentation.