-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
void sendSms() async {
TwilioResponse twilioResponse = await twilioFlutter.sendSMS(
toNumber: widget.phone,
fromNumber: BaseApi.messageServiceId,
// Ensure this is in E.164 format
messageBody: "Don't Share OTP with Anyone",
);
print("Send OTP ${twilioResponse.responseCode} and Success => ${twilioResponse.responseState.name} \nError => ${twilioResponse.errorData}");
if (twilioResponse.responseCode == 201) {
//getSms();
if (twilioResponse.metadata != null && twilioResponse.metadata!.isNotEmpty) {
// Accessing the first item in the list
var firstSms = twilioResponse.metadata!;
print("First SMS SID: ${firstSms['sid']}");
getSms();
} else {
print("No SMS data available.");
}
/*TwilioResponse response = await twilioFlutter.sendVerificationCode(verificationServiceId:BaseApi.accountSID,
recipient: '${twilioResponse.metadata!["0"]["sid"]}',
verificationChannel: VerificationChannel.SMS
);*/
CustomService.success(context, "SMS sent successfully");
} else {
CustomService.failure(context, "Failed to send SMS: ${twilioResponse.errorData}");
}
} perfectly work but sms not getting void getSms() async {
try {
// Fetch the list of SMS messages
final twilioResponse = await twilioFlutter.getSmsList();
// Check if the response contains messages
if (twilioResponse.metadata != null && twilioResponse.metadata!.isNotEmpty) {
// Get the first SMS message from the list
final firstSms = twilioResponse.metadata!;
// Get the SID of the first SMS
String firstSmsSid = firstSms['sid'];
print("First SMS SID: $firstSmsSid");
// Fetch the details of the SMS using the SID
final smsDetails = await twilioFlutter.getSMS(firstSmsSid);
// Print the details of the SMS
final keys = smsDetails.metadata!.map((key, value) => value);
print("Keys: ${keys}");
} else {
print("No SMS messages found.");
}
} catch (e) {
print("Error fetching SMS details: $e");
}
}
Metadata
Metadata
Assignees
Labels
No labels