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 🫡
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,
),
I'm currently working on deep links on Flutter. I managed to have almost everything working, except for this strange behaviour on Android 12 only. (iOS working also fine).
If I set a custom scheme for the deep links in the manifest, then Android 12 will make the https links to not open the app, but I can see the domain is actually just disabled if I go in "Applications -> Default Applications -> Link opening -> My App -> Web links", and enabling it solves the issue. If I don't set a custom scheme, then the domain is enabled on build.
It's currently only been tested on local debug builds if this matters.
As I said, beside this on Android 12, everything works as intended. I put this configuration :
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<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" />
<data android:host="my.domain.fr" />
<data android:scheme="https" />
<data android:scheme="http" />
<data android:scheme="custom" /> <------ Removing this makes a difference
</intent-filter>
I've set the assetlinks with the correct domain :
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "my.app.bundle",
"sha256_cert_fingerprints": ["AV:ER:YN:IC:ES:HA:25:6X"]
}
}]
From what I've understood, the links being enabled when not using the custom scheme are a good clue it works as intended, and the file is also said to be working fine with online testing tools.
The similar working method on iOS works without any issue.
I'm expecting the web links https://my.domain.fr to open in the app, but the option to do so is disabled in the app settings by default ONLY IF I use a custom scheme alongside.
you have to separate the intent-filter for the custom scheme.
from this
<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" />
<data android:host="my.domain.fr" />
<data android:scheme="https" />
<data android:scheme="http" />
<data android:scheme="custom" /> <------ Removing this makes a difference
</intent-filter>
to this
<intent-filter android:autoVerify="true" android:label="testHttpDeepLink">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="my.domain.fr" />
<data android:scheme="https" />
<data android:scheme="http" />
</intent-filter>
<intent-filter android:autoVerify="true" android:label="testAppDeepLink">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="custom" />
</intent-filter>
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);
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!
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>