Home > Back-end >  flutter url_launcher package is not working for iOS devices
flutter url_launcher package is not working for iOS devices

Time:05-30

I'm using flutter url_launcher: ^6.0.20 for my project. but it's not working for iOS devices but it's working for the android devices without any problem.

Column(
      mainAxisAlignment: MainAxisAlignment.center,
       children: [
        GestureDetector(
        onTap: () async {
        final contact = contactNumber;
        await launch('tel:$contact');
                               
       },
       child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
               const Text(
                'Hotline - ',
                style: TextStyle(
                fontSize: 25.0,
                fontWeight: FontWeight.bold,
                                       
                ),
              ),
             Text(
              contactNumber,
              style: const TextStyle(
                     fontSize: 25.0,
                     fontWeight: FontWeight.bold,
                     decoration: TextDecoration.underline),
                     ),
                   ],
                 ),
              ),

contactNumber is coming form the backend api. and I've assigned that value to contactNumber variable.

here is the package below,

https://pub.dev/packages/url_launcher

It's working properly for android. not working for the iOS. there is no error on the code. Is the problem in the package.?

CodePudding user response:

Create a method for make a call.

 Future<void> _makePhoneCall(String phoneNumber) async {
  final Uri launchUri = Uri(
  scheme: 'tel',
  path: phoneNumber,
  );
await launchUrl(launchUri);
 }

then call on onPressed:

_makePhoneCall("01*********");

don't forget to add permission on info.plist.

if you add dependency on runtime, it may be not working. So stop the run and build the project again

CodePudding user response:

try it, it was worked for me launch("tel://1234567890");

  • Related