I'm using url_launcher: ^5.4.10 for launching different url scheme but is that external link is working fine on ios simulator but not working opening phone dialpad and default email address while its working fine on android devices
i tested it on ios simulator not real device
if i try to open dialpad here is exception
{PTS: 6.000 s, decode: 32.021 ms},
]
flutter: could not launch tel:+18002509646
when i try open email box here is exception i received
*** First throw call stack:
(
0 CoreFoundation 0x00000001084f4a2a __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00000001083874ce objc_exception_throw + 48
2 Foundation 0x0000000107f2e808 -[__NSConcreteURLComponents initWithString:] + 0
3 CoreServices 0x000000010f7c2db2 -[_LSURLOverride initWithOriginalURL:checkingForAvailableApplications:] + 136
4 CoreServices 0x000000010f7c35b5 -[_LSURLOverride initWithOriginalURL:] + 22
5 CoreServices 0x000000010f7c3d97 _ZN14LaunchServices12URLOverridesL20getURLOverrideCommonEP5NSURL + 374
6 CoreServices 0x000000010f7c3c10 -[LSApplicationWorkspace(LSURLOverride) URLOverrideForURL:] + 12
7 UIKitCore <…>
my code url launcher
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart';
class Contactcus extends StatelessWidget {
void customLaunch(command) async {
if (await canLaunch(command)) {
await launch(command);
} else {
print(' could not launch $command');
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 10),
child: Container(
child: Column(
children: <Widget>[
Text(
'Contact us'.toUpperCase(),
style: TextStyle(
fontFamily: 'TT NORMS',
fontWeight: FontWeight.w100,
fontSize: 25,
),
),
Padding(
padding: EdgeInsets.only(left: 0),
child: Row(
children: <Widget>[
Expanded(
child: SizedBox(
child: ListTile(
leading: Icon(Icons.phone,
size: 25, color: Colors.black87),
onTap: () {
customLaunch('tel:+18001569647');
},
title: Text(
'Phone'.toUpperCase(),
style: TextStyle(
fontFamily: 'TT NORMS',
fontSize: 20,
fontWeight: FontWeight.w100,
),
),
subtitle: Text(
'1 (800) 250-9646 ',
style: TextStyle(
color: Colors.black87,
),
),
),
),
),
],
),
),
Padding(
padding: EdgeInsets.only(left: 0),
child: Row(
children: <Widget>[
Expanded(
child: SizedBox(
child: ListTile(
leading: Icon(Icons.email,
size: 25, color: Colors.black87),
onTap: () {
customLaunch(
'mailto:[email protected]?subject=Feed%20back&body=Write your%20feedback');
},
title: Text(
'Email',
style: TextStyle(
fontFamily: 'TT NORMS',
fontWeight: FontWeight.w100,
fontSize: 20
),
),
subtitle: Text(
'[email protected]',
style: TextStyle(color: Colors.black87,
),
),
),
),
),
],
),
),
Padding(
padding: EdgeInsets.only(left: 0),
child: Row(
children: <Widget>[
Expanded(
child: SizedBox(
child: ListTile(
leading: Icon(Icons.location_on,
size: 28, color: Colors.black87),
onTap:(){
customLaunch('https://www.google.ca/maps/place/3434+Cawthra+Rd,+Mississauga,+ON+L5A+2X7/@43.6025224,-79.6147441,17z/data=!3m1!4b1!4m5!3m4!1s0x882b470c94e668ff:0x62c956c363a795d9!8m2!3d43.6025185!4d-79.6125554');
},
title: Text(
'MAILING ADDRESS',
style: TextStyle(
fontFamily: 'TT NORMS',
fontWeight: FontWeight.w100,
fontSize: 20
),
),
subtitle: Text(
'Att: Living Hope TV\n'
'Cornerstone Asian Church\n'
'3434 Cawthra Rd\n'
'Mississauga, ON L5A 2X7\n'
'Canada',
style: TextStyle(
color: Colors.black87,
),
),
),
),
),
],
),
),
Padding(
padding: EdgeInsets.only(top: 70),
child: Row(
mainAxisAlignment:MainAxisAlignment.center,
children: <Widget>[
IconButton(
icon: Image.asset('images/youtube.png'),
iconSize: 30,
onPressed: () {
customLaunch('https://www.youtube.com/channel/UCsnohhaCJvkT3prNnMwlvnA');
},
),
IconButton(
icon: Image.asset('images/twitter.png'),
iconSize:30,
onPressed: () {
customLaunch('https://twitter.com/livinghopetv1');
},
),
IconButton(
icon: Image.asset('images/instagram.png'),
iconSize: 30,
onPressed: () {
customLaunch('https://www.instagram.com/livinghopetv/');
},
),
IconButton(
icon: Image.asset('images/facebook.png'),
iconSize: 30,
onPressed: () {
customLaunch('https://www.facebook.com/livinghopetelevision');
},
),
IconButton(
icon: Image.asset('images/web.png'),
iconSize: 30,
onPressed: () {
customLaunch('https://www.livinghopetv.org');
},
),
],
),
)
],
),
),
),
],
),
),
);
}
}
I have a suggestion to make, can you try giving the command like this:
1. Code Check
command = "tel://214324234"
// Also, try using Future in place of void
Future<void> customLaunch(command) async {
if (await canLaunch(command)) {
await launch(command);
} else {
print(' could not launch $command');
}
}
2. Formatting Check: Do check, if there is no space between tel:
and the <phone number>
, it has to be written without space, that is, tel:<phone_number>
3. Update Check: Also, there is a new update, that is, 5.5.0
, please upgrade your packages accordingly in your pubspec.yaml
file. Why, am I telling you cos, sometimes, previous version does not support some functionalities in your Mobile Platform
4. Real Device Check: Sometimes what happens is, the simulator does not support some functionalities. I would request you to please get a real iOS Device
, and check it. If the above doesn't solve your issue, this might do the job