ElevatedButton(
onPressed: () async {
const url ='https://www.facebook.com';
if (await canLaunch(url)) {
await launch(url,forceWebView: true,enableJavaScript: true);
} else {
// can't launch url
}
},
);
I/UrlLauncher( 7566): component name for https://www.facebook.com is null
Add the queries for each platform, follow the documentation in this link URL Launcher API Reference
iOS
Add any URL schemes passed to canLaunchUrl as LSApplicationQueriesSchemes entries in your Info.plist file.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
<string>http</string>
</array>
Android
Starting from API 30 Android requires package visibility configuration in your AndroidManifest.xml otherwise canLaunchUrl will return false. A element must be added to your manifest as a child of the root element.
<queries>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<!-- If your app makes calls -->
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<!-- If your sends SMS messages -->
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="smsto" />
</intent>
<!-- If your app sends emails -->
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
This works for me!
Related
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. Pleaseenter 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,
),
Flutter ,My Launcher is not working With Link Widget of Url Launcher.
final websiteUri = Uri.parse('https://flutter.dev');
Link(
uri: websiteUri,
target: LinkTarget.blank,
builder: (context, openLink) => TextButton(
onPressed: openLink,
child: Text(websiteUri.toString()),
),
)
use launchUrlString from the url_launcher package instead:
final websiteUri = 'https://flutter.dev';
onpressed:launchUrlString(websiteUri);
I just updated my AndroidManifest.xml , according to: https://pub.dev/packages/url_launcher#android and https://developer.android.com/training/package-visibility/use-cases#check-browser-available
and finally i add thi to AndroidManifest.xml like:
<queries>
<!-- If your app checks for SMS support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="sms" />
</intent>
<!-- If your app checks for call support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tel" />
</intent>
<!-- Place inside the <queries> element. -->
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
</queries>
It worked Perfectly no issues 🫡
My Code is not working. Do not opening email via this code. Their shows a null error.
Add this in AndroidManifest.xml just above of application
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
</intent>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
In launch you are converting it to a string whereas it would require a uri to be launched. Remove .toString from the launch method
launch(emailLaunchUri);
Hi can anyone help me I just follow the instruction here: developer.android.com/about/versions/12/behavior-changes-12#exported
but still I am getting the same error " You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without 'android:exported' property set. This file can't be installed on Android 12 or higher. See: developer.android.com/about/versions/12/behavior-changes-12#exported"
when uploading the file to google play consule App bundles release
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.HatidRider.app"
xmlns:tools="http://schemas.android.com/tools">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
<application
android:name=".App"
tools:replace="android:label"
android:label="Hatid-PH Delivery"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
android:icon="#mipmap/ic_launcher">
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCaCSJ0BZItSyXqBv8vpD1N4WBffJeKhLQ"/>
<activity
android:name=".MainActivity"
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"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<service
android:name="com.HatidRider.app.BackgroundService"
android:enabled="true"
android:exported="true" />
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.HatidRider.app"
xmlns:tools="http://schemas.android.com/tools">
<!-- io.flutter.app.FlutterApplication is an
android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate
method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
<application
android:name=".App"
tools:replace="android:label"
android:label="Hatid-PH Delivery"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
android:icon="#mipmap/ic_launcher">
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCaCSJ0BZItSyXqBv8vpD1N4WBffJeKhLQ"/>
<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"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<service
android:name="com.HatidRider.app.BackgroundService"
android:enabled="true"
android:exported="true" />
<meta-data
android:name="flutterEmbedding"
android:value="2" />
Check if it works now, I have explicity set android:exported = "true"
as you have launcher and in other places
I am trying to integrate Branch,io in my flutter project via flutter_branch_sdk. I have followed this tutorial https://www.youtube.com/watch?v=H3ihnIrtw_Q. I can generate link and it redirects and opens the app but not to specific screen of the app. However, when I run validateSdkIntegration method. it print this.
3. Verifying application package name ...
D/BranchSDK_Doctor(27965): Passed
D/BranchSDK_Doctor(27965): 4. Checking Android Manifest for URI based deep link config ...
D/BranchSDK_Doctor(27965): ** ERROR ** : No intent found for opening the app through uri
Scheme 'de://'.Please add the intent with URI scheme to your Android manifest.
D/BranchSDK_Doctor(27965): Please follow the link for more info
https://help.branch.io/developers-hub/docs/android-basic-integration#section-configure-app
My AndroidManifest.xml file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.dhaka_eats">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<queries>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<!-- If your app makes calls -->
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<!-- If your app emails -->
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
<application android:label="#string/app_name" android:name="io.branch.referral.BranchApp" android:icon="#mipmap/launcher_icon">
>
<activity android:name=".MainActivity" android:launchMode="singleTask" android:theme="#style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:screenOrientation="portrait" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Branch URI Scheme -->
<intent-filter>
<data android:scheme="de" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<!-- Branch App Links -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- example-alternate domain is required for App Links when the Journeys/Web SDK and Deepviews are used inside your website. -->
<data android:scheme="https" android:host="#string/deeplink_test_link" />
<data android:scheme="https" android:host="#string/deeplink_alternative_test_link" />
<data android:scheme="https" android:host="#string/deeplink_test_link" />
<data android:scheme="https" android:host="#string/deeplink_alternative_test_link" />
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.facebook.CustomTabActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="#string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyAejfMVUk4Bjnslt32AqxLSuJHOa-sdfsdf" />
<meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="#style/NormalTheme" />
<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="#drawable/launch_background" />
<!--
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" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id" />
<activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="#string/app_name" />
<!-- Branch init -->
<meta-data android:name="io.branch.sdk.BranchKey" android:value="#string/branch_io_sdk_live_key" />
<!-- Branch testing (TestMode "true" to simulate fresh installs on dev environment) -->
<meta-data android:name="io.branch.sdk.BranchKey.test" android:value="#string/branch_io_sdk_test_key" />
<meta-data android:name="io.branch.sdk.TestMode" android:value="false" />
<meta-data android:name="branch_enable_log" android:value="true" />
<meta-data android:name="branch_enable_facebook_ads" android:value="false" />
</application>
add new scheme under domain configuration for example <data android:scheme="examplelink" />
this code is based on your scheme:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- example-alternate domain is required for App Links when the Journeys/Web SDK and Deepviews are used inside your website. -->
<data android:scheme="https" android:host="#string/deeplink_test_link" />
<data android:scheme="https" android:host="#string/deeplink_alternative_test_link" />
<data android:scheme="https" android:host="#string/deeplink_test_link" />
<data android:scheme="https" android:host="#string/deeplink_alternative_test_link" />
<data android:scheme="ed"/>
</intent-filter>