简体   繁体   English

无法打开 launchUrl 电报以加入群组/频道

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

I have a Icon button.我有一个图标按钮。 Using url_launcher: ^6.1.8 package. My goal is when user will tap on the button user will be redirected to telegram and will get a opion for joining the channel.使用 url_launcher:^6.1.8 package。我的目标是当用户点击按钮时用户将被重定向到电报并获得加入频道的选项。 but I am facing issue of.net::ERR_UNKNOWN_URI_scheme in phone.但我在电话中面临 .net::ERR_UNKNOWN_URI_scheme 的问题。 Also provided picture ofdebug console.还提供了调试控制台的图片。 NB: when I change the url to google's url it works.注意:当我将 url 更改为谷歌的 url 时,它会起作用。 Please enter image description here help在此处输入图片描述帮助

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

enter image description here SS of debug console.. for permission i tried在此处输入图像描述调试控制台的 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>

I tested as follows and it worked.我测试如下并且有效。 Please give it a try.请试一试。

Don't worry if you see a warning in this section that a deprecated feature is being used.如果您在本节中看到有关正在使用已弃用功能的警告,请不要担心。

_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