5/27/1
This commit is contained in:
@@ -13,24 +13,24 @@ void launchCommunication(
|
||||
String method, String contactInfo, String message) async {
|
||||
String url;
|
||||
|
||||
// Encode the message
|
||||
String encodedMessage = Uri.encodeComponent(message);
|
||||
|
||||
if (Platform.isIOS) {
|
||||
switch (method) {
|
||||
case 'phone':
|
||||
url = 'tel:$contactInfo';
|
||||
break;
|
||||
|
||||
case 'sms':
|
||||
url = 'sms:$contactInfo?body=$message';
|
||||
url = 'sms:$contactInfo?body=$encodedMessage';
|
||||
break;
|
||||
|
||||
case 'whatsapp':
|
||||
url = 'https://api.whatsapp.com/send?phone=$contactInfo&text=$message';
|
||||
url =
|
||||
'https://api.whatsapp.com/send?phone=$contactInfo&text=$encodedMessage';
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
url = 'mailto:$contactInfo?subject=Subject&body=$message';
|
||||
url = 'mailto:$contactInfo?subject=Subject&body=$encodedMessage';
|
||||
break;
|
||||
|
||||
default:
|
||||
print('Method not supported on iOS');
|
||||
return;
|
||||
@@ -40,19 +40,15 @@ void launchCommunication(
|
||||
case 'phone':
|
||||
url = 'tel:$contactInfo';
|
||||
break;
|
||||
|
||||
case 'sms':
|
||||
url = 'sms:$contactInfo?body=$message';
|
||||
url = 'sms:$contactInfo?body=$encodedMessage';
|
||||
break;
|
||||
|
||||
case 'whatsapp':
|
||||
url = 'whatsapp://send?phone=$contactInfo&text=$message';
|
||||
url = 'whatsapp://send?phone=$contactInfo&text=$encodedMessage';
|
||||
break;
|
||||
|
||||
case 'email':
|
||||
url = 'mailto:$contactInfo?subject=Subject&body=$message';
|
||||
url = 'mailto:$contactInfo?subject=Subject&body=$encodedMessage';
|
||||
break;
|
||||
|
||||
default:
|
||||
print('Method not supported on Android');
|
||||
return;
|
||||
@@ -62,8 +58,8 @@ void launchCommunication(
|
||||
return;
|
||||
}
|
||||
|
||||
if (await canLaunchUrl(Uri.parse(url))) {
|
||||
launchUrl(Uri.parse(url));
|
||||
if (await canLaunch(url)) {
|
||||
await launch(url);
|
||||
} else {
|
||||
print('Could not launch $url');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user