1/25/1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'dart:io';
|
||||
|
||||
void launchUrl1(String url) async {
|
||||
void showInBrowser(String url) async {
|
||||
if (await canLaunchUrl(Uri.parse(url))) {
|
||||
launchUrl(Uri.parse(url));
|
||||
} else {
|
||||
@@ -12,22 +13,53 @@ void launchCommunication(
|
||||
String method, String contactInfo, String message) async {
|
||||
String url;
|
||||
|
||||
switch (method) {
|
||||
case 'phone':
|
||||
url = 'tel:$contactInfo';
|
||||
break;
|
||||
case 'sms':
|
||||
url = 'sms:$contactInfo?body=$message';
|
||||
break;
|
||||
case 'whatsapp':
|
||||
url = 'whatsapp://send?phone=$contactInfo&text=$message';
|
||||
break;
|
||||
case 'email':
|
||||
url = 'mailto:$contactInfo?subject=Subject&body=$message';
|
||||
break;
|
||||
default:
|
||||
print('Invalid communication method');
|
||||
return;
|
||||
if (Platform.isIOS) {
|
||||
switch (method) {
|
||||
case 'phone':
|
||||
url = 'tel:$contactInfo';
|
||||
break;
|
||||
|
||||
case 'sms':
|
||||
url = 'sms:$contactInfo?body=$message';
|
||||
break;
|
||||
|
||||
case 'whatsapp':
|
||||
url = 'https://api.whatsapp.com/send?phone=$contactInfo&text=$message';
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
url = 'mailto:$contactInfo?subject=Subject&body=$message';
|
||||
break;
|
||||
|
||||
default:
|
||||
print('Method not supported on iOS');
|
||||
return;
|
||||
}
|
||||
} else if (Platform.isAndroid) {
|
||||
switch (method) {
|
||||
case 'phone':
|
||||
url = 'tel:$contactInfo';
|
||||
break;
|
||||
|
||||
case 'sms':
|
||||
url = 'sms:$contactInfo?body=$message';
|
||||
break;
|
||||
|
||||
case 'whatsapp':
|
||||
url = 'whatsapp://send?phone=$contactInfo&text=$message';
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
url = 'mailto:$contactInfo?subject=Subject&body=$message';
|
||||
break;
|
||||
|
||||
default:
|
||||
print('Method not supported on Android');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
print('Platform not supported');
|
||||
return;
|
||||
}
|
||||
|
||||
if (await canLaunchUrl(Uri.parse(url))) {
|
||||
|
||||
Reference in New Issue
Block a user