简体   繁体   中英

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. but I am facing issue of.net::ERR_UNKNOWN_URI_scheme in phone. Also provided picture ofdebug console. NB: when I change the url to google's url it works. 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

<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,
  ),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM