簡體   English   中英

無法打開 launchUrl 電報以加入群組/頻道

[英]can't open launchUrl telegram to join group/channel

我有一個圖標按鈕。 使用 url_launcher:^6.1.8 package。我的目標是當用戶點擊按鈕時用戶將被重定向到電報並獲得加入頻道的選項。 但我在電話中面臨 .net::ERR_UNKNOWN_URI_scheme 的問題。 還提供了調試控制台的圖片。 注意:當我將 url 更改為谷歌的 url 時,它會起作用。 在此處輸入圖片描述幫助

IconButton(
                  onPressed: () async {
                    await launchUrl(Uri.parse("https://t.me/jobcontainer"));
                  },
                  icon: const Icon(
                    FontAwesomeIcons.telegram,
                    color: Colors.blue,
                  ),
                  iconSize: 45,
                ),

在此處輸入圖像描述調試控制台的 SS .. 以獲得我嘗試過的許可

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.job_age_calculator">
    
    <!--    Provide required visibility configuration for API level 30 and above -->
    <queries>
        <!-- To open phone's dialer app -->
        <intent>
            <action android:name="android.intent.action.DIAL" />
            <data android:scheme="tel" />
        </intent>
        <!-- To send SMS messages -->
        <intent>
            <action android:name="android.intent.action.SENDTO" />
            <data android:scheme="smsto" />
        </intent>
        <!-- To open email app -->
        <intent>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="*/*" />
        </intent>
          <!-- To opens https URLs -->
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>
    </queries>



 


   <application
        android:label="job_age_calculator"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
    
    <!-- Permissions-->
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
        <!-- Needed only if your app looks for Bluetooth devices.
         If your app doesn't use Bluetooth scan results to derive physical
         location information, you can strongly assert that your app
         doesn't derive physical location. -->
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    
</manifest>

我測試如下並且有效。 請試一試。

如果您在本節中看到有關正在使用已棄用功能的警告,請不要擔心。

_launchURL(url) async {
  if (await canLaunch(url)) {
    await launch(url);
  } else {
    throw 'Could not launch $url';
  }
}




IconButton(
    onPressed: () async {
      await launchUrl(Uri.parse("https://t.me/jobcontainer"));
    },
    icon: const Icon(
      Icons.telegram,
      color: Colors.blue,
    ),
    iconSize: 45,
  ),

暫無
暫無

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

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