I can't open mail via Launcher URL in flutter - flutter

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

Related

Flutter / Android 12 - Using deep links with a custom scheme makes the https scheme disabled by default

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>

I Cant Open Flutter URL Via Link

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 🫡

why flutter give me url null in url launcher?

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!

Branch.io No intent found for opening the app through uri Scheme 'de://'.Please add the intent with URI scheme to your Android manifest

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>

How to open pdf file in flutter app when a user clicks on a pdf file in file manager

i wanted to know how to make my app as a default pdf viewer. Please see the screenshot below :
So when a user clicks on the pdf file the flutter app should open it. and should be visible in the list of pdf openers.
check out receive_sharing_intent
and add below code in your manifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
android:maxSdkVersion="28"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>