Flutter url_launcher软件包不适用于iOS设备

发布于 2025-02-02 17:10:08 字数 1309 浏览 3 评论 0原文

我正在为我的项目使用Flutter url_launcher: ^6.0.20。但这对iOS设备不起作用,但是它对Android设备无问题。

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即将形成后端API。我将该值分配给了Contactnumber变量。

这是下面的软件包,

https://pub.dev/packages/url_launcher

适当适合Android。不为iOS工作。代码没有错误。包装中的问题吗?

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.?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泪眸﹌ 2025-02-09 17:10:08

创建一种呼叫的方法。

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

然后致电打开:

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

不要忘记在info.plist上添加权限。

如果添加了对运行时的依赖性,则可能无法正常工作。所以停下来
再次运行并构建项目

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

东走西顾 2025-02-09 17:10:08

试试看,它是为我工作启动(“ Tel:// 1234567890”);>

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文