I'm trying to have my application use app links, but even though I went through all the steps and my assetlinks.json file is being requested, the disambiguation box still shows up. I tried the same steps with a native android app, and it worked without showing the box. Here is what I did:
1- Create a new flutter application.
2- Signed my application following the instructions on https://flutter.dev/docs/deployment/android
3- Add the following to my activity in AndroidManifest.xml
<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:scheme="https"
android:host="<example.come>" />
</intent-filter>
I replaced example.com with my own domain, have https enabled, and serving /.well-known/assetlinks.json
Here is the content of assetlinks.json
[
{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "com.example.app",
"sha256_cert_fingerprints": [
"hash_of_app_certificate"
]
}
}
]
I replaced com.example.app with my own, and changed the hash. I used this command to obtain the hash
keytool -list -v -keystore <keystore path> -alias <key alias> -storepass <store password> -keypass <key password>
4- Ran flutter build apk and installed the app on my device. I can tell that assetlinks.json has been requested from the server, but the selection box still shows up.
I tested my assertlinks.json on https://developers.google.com/digital-asset-links/tools/generator and it says it is successful so whatever is wrong is on the app side.
What am I missing or doing wrong?
Here is my flutter doctor --verbose
[√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [Version 10.0.19041.746], locale en-US)
• Flutter version 1.22.5 at C:\flutter
• Framework revision 7891006299 (7 weeks ago), 2020-12-10 11:54:40 -0800
• Engine revision ae90085a84
• Dart version 2.10.4
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\Moneer\AppData\Local\Android\Sdk
• Platform android-29, build-tools 29.0.3
• ANDROID_HOME = C:\Users\Moneer\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[!] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.52.1)
• VS Code at C:\Users\Moneer\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.18.1
[√] Connected device (1 available)
• sdk gphone x86 64 arm64 (mobile) • emulator-5554 • android-x64 • Android 11 (API 30) (emulator)
! Doctor found issues in 1 category.
If anyone is still struggling with this (3.5 years later, now that Android 13 is common everywhere), here are my findings:
If you’re pressing a link on mobile and it’s opening the browser instead of the app, the source of the issue is most likely Android App Links (if you’re on Android, for iOS see Universal Links)
For the mobile app to be open when clicking a link outside the app, there are two factors needed (EDIT: Maybe 3):
That would be https://www.yourdomain.com/.well-known/assetlinks.json
You can verify that using https://developers.google.com/digital-asset-links/tools/generator or by going to the https://play.google.com/console, selecting the correct app and from the left side menu going to Grow Users → Deep links
Under the section “Domains” if there are any issues you can check the right arrow and if it’s an issue with assetlinks.json it would recommend what changes you need to make
!IMPORTANT! If you make a deployment to your domain - wait a few minutes for the console to realize that has happened. The fix isn’t recognized immediately
You NEED the following intent filter:
<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="www.yourdomain.com"
android:scheme="https"/>
You might also need <meta-data android:name="flutter_deeplinking_enabled" android:value="true" /> but I’m not sure.
You might also need the code below in your firebase.json but again, I’m not sure
"hosting": {
"public": "flutter/build/web",
"rewrites": [
{
"source": "/auth/**",
"dynamicLinks": true
},
{
"source": "**",
"destination": "/index.html"
}
]
},
For some reason I didn’t manage to make links work for a local build of an android app (even when trying in RELEASE mode). However, when running the version of my app I download from GooglePlay, it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With