I am creating a web app in flutter. It is used for entering students' attendance into the database.
What I want to achieve is to send SMS to the parents of absent students. I came upon flutter_sms 2.3.1 and it is supported for Android, iOS and web as per the pub.dev docs but I could not find any reference about sending SMS in flutter web using the same package. Please let me know if there is any way to achieve this task that I want.
Following is the code for sending the SMS but not working in Flutter web.
void _sendSMS(String message, List<String> recipents) async {
String _result = await sendSMS(message: message, recipients: recipents)
.catchError((onError) {
print(onError);
});
print(_result);
}
Twilio API would totally help you sending sms/whatsapp messages from any plaform automatically
Related
I am developing sms reading app using the flutter telephony package. Everything is working fine, but there is a problem when the mobile has two sim cards. I am unable to track which sim card is receiving SMS. Can anyone help me to achieve my goal?
Here is code
onMessage(SmsMessage message) async {
print('sid: ${message.subscriptionId}');
ToasterShow('sub= ${message.subject}');
String? operatorName = await telephony.simOperatorName;
}
here subscriptionId return null.
Hope anyone help me.
Thanks
I need a callback URL so that when a mobile money API completes a payment transaction, my app can receive a message about the transaction status. I'm building a flutter app. I have seen that cloud functions may be the answer. So, I need help on how to get started on creating this callback URL.
I'm yet to try anything because all the material I have seen talks about JavaScript and websites. I need material on doing this in the flutter mobile app.
look at this snippet I hope it helps
// await for your first function t
await moneyFuntion()
.whenComplete(() async => await anotherAPIFuntion())
.onError((error, stackTrace) {
log("$error");
How can I send a text directly to a specific phone number on Viber? or to a specific person on Facebook messenger?
with whatsapp I'm using url_launcher with whatsapp with below code, and it is working fine.
var whatsapp_url = "whatsapp://send?phone=" + whatsapp_number + "&text=hellooo";
try {
await launchUrl(Uri.parse(whatsapp_url));
} catch (e) {
print('could not launch whatsapp');
}
I tried using the same package with Viber using ("viber://chat?number=") and Facebook messenger using ('m.me/username') but both are just opening a web site and not opening the mobile App and not finding the phone number or the messenger chat.
I need to do a similar thing by clicking an IconButton to open a specific chat on Viber and another IconButton to open a specific Facebook messenger chat.
I found a solution in case someone needed - I used the same url_launcher library.
Viber:
var viber_link = "viber://chat/?number=$Country_Code$Mobile_Number&draft=$Message_to_be_sen”
;
Viber doesn’t need ‘+’ sign when writing the country code
Facebook Messenger:
var facebook_messenger_link = 'https://m.me/$FaceBook_Name?text=$Message_to_be_sent;
Facebook Name can be found by clicking on the profile picture on Facebook and checking the URL, it comes after ‘https://www.facebook.com/{FB_Name}’
Telegram:
var telegram_link = 'https://t.me/+$Country_Code$Mobile_Number&draft=$Message_to_be_sen';
Telegram needs the ‘+’ sign when writing the country code
Then used this code for launching it:
final Uri app_link_uri = Uri.parse(app_link);
try {
await launchUrl(
app_link_uri,
mode: LaunchMode.externalApplication,
);
} catch (error) {
print(‘error’ catching: $error);
}
How can I send for example SMS code verification in Flutter (without Firebase Auth because I have MySQL database with PHP connection).
I have tried :
Future<void> _sendCode(String phoneNumber) async
{
phoneNumber = "XX XX XX XX XX";
String code = _createCode();
String message = "The code is $code";
String uri = 'sms:$phoneNumber?body=$message';
await launchUrlString(uri);
}
And many other things, but it open messaging on my device. I want the code to be sent automatically.
I have tried to find out how to send a message from PHP but without satisfactory result.
You can try flutter_otp package I think it's the best option,
You can visit https://pub.dev/packages/flutter_otp for more info,
You can also use url_launcher package.
I am using firebase_messaging library with firebase for push notification in flutter. The documentation says that myBackgroundMessageHandler is called when the app is in background. But it has not happened.
I would like to format the title and the body of the notification before it is shown. I am getting notifications when the app is in the background but that particular method is not called. Currently it just shows the exact text sent by backend in title and body.
Is there something I have to do to enable(?) this method? I have it in my fcm.configure method:
_fcm.configure(
onBackgroundMessage: myBackgroundMessageHandler,
)
static Future<Map<String, dynamic>> myBackgroundMessageHandler(Map<dynamic, dynamic> message) async {
//some code here
return message;
}
Thanks in advance!
I had the same problem.
onBackgroundMessage apparently gets triggered only for data-messages.
See the difference here:
https://firebase.google.com/docs/cloud-messaging/concept-options
With FCM, you can send two types of messages to clients:
Notification messages, sometimes thought of as "display messages."
These are handled by the FCM SDK automatically.
Data messages, which
are handled by the client app.
In my case I had to remove the notification (subject, body etc), but also styling like bigpicture completely. Try sending only a data object.