簡體   English   中英

顫振 url_launcher 包不適用於 iOS 設備

[英]flutter url_launcher package is not working for iOS devices

我正在為我的項目使用顫振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。 代碼沒有錯誤。 是包的問題嗎?

創建一個調用方法。

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

然后調用 onPressed:

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

不要忘記在 info.plist 上添加權限。

如果您添加對運行時的依賴,它可能無法正常工作。 所以停止運行並再次構建項目

試試看,它對我launch("tel://1234567890");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM