Android: Deep linking web urls - android

I want to integrate deep-linking for web-urls in Android. However, I couldn't get it working. Following are the steps I'm following:
Step 1. 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="niksguitarist.000webhostapp.com" android:pathPrefix="/asset"/>
</intent-filter>
<meta-data android:name="asset_statements" android:resource="#string/asset_statements" android:autoVerify="true"/>
Step 2. res/values/strings.xml:
<string name="asset_statements">
[{
\"relation\": [\"delegate_permission/common.share_location\"],
\"target\": {
\"namespace\": \"web\",
\"site\": \"https://niksguitarist.000webhostapp.com/\"
}
}]
</string>
Step 3. Host assetLinks on server:
https://niksguitarist.000webhostapp.com/.well-known/assetlinks.json
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.sprinklr.distributedapp",
"sha256_cert_fingerprints": ["A8:D4:5F:DC:AE:67:D6:90:46:23:07:8B:23:89:0B:11:AB:49:4E:B0:C7:87:50:0C:59:32:01:A0:4A:88:1A:5A"]
}
}]
Now, when I try to open https://niksguitarist.000webhostapp.com/asset on mobile browser (chrome or firefox), it doesn't route me to my app.
Can someone please suggest on what I am doing wrong?

App link won't work if you are trying to open url directly from browser. It would only work if you are trying to open url from a non-browser app - note, chat or any other app

Related

Android deep-links - Error 1024 when in debug/emulator

I have added my assetlinks.json to my website within the .well-known folder and confirmed the file is being served
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.******.*********",
"sha256_cert_fingerprints":
["23:DB:...."]
}
}]
I have added auto verify and data tags to the AndroidManifest.xml though as it is a capacitor application I wasn't 100% which intent-filter to add it to
<application>
<activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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:scheme="https"/>
<data android:host=*****.*******.com" />
</intent-filter>
</activity>
The deep linking works fine when I manually add it within the phone/emulator but does not seem to "auto verify".
I tried the following adb commands
adb shell pm verify-app-links --re-verify com.*****.*******
then
adb shell pm get-app-links com.****.*******
And get back
com.*****.******:
ID: b5eb46a8-eb37-44ff-8b50-c6bc92402d34
Signatures: [23:DB:....]
Domain verification state:
*****.*****.com: 1024
I suppose my first question is - Should I even expect this to work with the application running in debug (unpublished/signed) and if so - any help?
according to the android app, link documentation: Do not publish your app with dev/test URLs in the manifest file that may not be accessible to the public (such as any that are accessible only with a VPN). A work-around in such cases is to configure build variants to generate a different manifest file for dev builds.

Android App Links on Android 12 - `legacy_failure`

I'm working on a React Native app that is supposed to open when you click on a link that leads to the website. The iOS and Android 10 versions work just fine.
However, on Android 12 instead of opening the app the link opens in the browser. I have .well-known/assetlinks.json file in place that looks like this:
[
{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "com.example",
"sha256_cert_fingerprints": [
"AA:BB:CC:DD:EE:FF...", // staging key fingerprint
"AA:BB:CC:DD:EE:FF..." // prod key fingerprint
]
}
}
]
I read this article through and through trying to find a solution to this.
I tried running adb shell pm verify-app-links --re-verify com.example and executing adb shell pm get-app-links com.example, but I keep getting the result:
Domain verification state:
example.com: legacy_failure
I also tried the Statement List Generator and Tester tool by Google. It says that there's no app deep linking permission on www.example.com, but after a few more tries it shows success.
My AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example">
<application ...>
<.../>
<activity ...>
<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"/>
<data android:host="example.com" />
</intent-filter>
<.../>
</activity>
<.../>
</application>
</manifest>
I tried changing android:host to www.example.com or *.example.com but that didn't seem to work either.

Deep link not working in Android 12 after publish assetlinks.json to domain and also put autoverify true in intent filter Android

I know this question is asked before but I didn't find any correct answer that solve my issue
Deep link is working on android 11 or lower device but not working in android 12 device
Here example.com is for understanding
Pls check below code for open activity by deep link
<activity
android:name=".splash.SplashActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<data
android:host="example.com"
android:scheme="https" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
I also put meta data thing for deep link
<meta-data
android:name="asset_statements"
android:resource="#string/asset_statements"/>
<string name="asset_statements" translatable="false">[{\"include\": \"https://example.com/.well-known/assetlinks.json\"}]</string>
I also check that assetlinks.json file is valid or not by using this link
https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://example.com&relation=delegate_permission/common.handle_all_urls
And there is no error that shows the json file is incorrect
Our assetlinks.json file is like this
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "example.com",
"sha256_cert_fingerprints":
["9C:BC:79:E2:77:18:E4:23:F9:5B:B2:5A:...",
"E4:37:19:8A:52:A9:6E:7C:A0:DE:62:FA:..",
"15:39:35:57:FB:8E:A9:40:84:8C:3E:E7:..."
]
}
},
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "example.com.developement",
"sha256_cert_fingerprints":
["9C:BC:79:E2:77:18:E4:23:F9:5B:B2:5A:5A:9E:..",
"15:39:35:57:FB:8E:A9:40:84:8C:3E:E7:DF:9B:..."]
}
},{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "example.com.qa",
"sha256_cert_fingerprints":
["9C:BC:79:E2:77:18:E4:23:F9:5B:B2:5A:5A:9E..",
"15:39:35:57:FB:8E:A9:40:84:8C:3E:E7:DF:9B:6D:..."
]
}
}]
WE get our sha256 key from google play console -> App integrity -> App signing
and from android studio
gradle -> gradle signingReport
Pls give suggestions what we're doing wrong, This is not working in android 12 device it's open the link in default browser but working in android 11 or lower device
If you are using firebase deep linking url host exmple.page.link then change it to domain.com where your /.well-known/assetlinks.json file locate.

Android App Link - Testing the flow in local environment

I'm trying to check how App Links work on android.
Here is what I have done so far -
Set up a local server with MAMP, apache points to port 80.
Created .well-known in the htdocs & also put the assetlinks.json in the created dir.
I am able to access it using - http://192.168.0.78/.well-known/assetlinks.json
where 192.168.0.78 is my lan ip. I generated the SHA using the keytool command.
Here are the contents of the file assetlinks.json:
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.pbc.deeplinking_demo",
"sha256_cert_fingerprints":
["D9:29:00:B9:30:F1:24:A0:E7:7A:58:74:43:C6:06:FF:F6:16:BB:42:F3:A2:16:10:5D:81:27:37:3A:E5:A6:14"]
}
}]
Set up an android app with the applicationId : com.pbc.deeplinking_demo
Added the intent-filters with autoVerify=true to the activity
implementation below -
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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:scheme="http" />
<data
android:host="192.168.0.78" />
</intent-filter>
</activity>
With this config, I continue to see the disambiguation dialog asking me to choose between the default browser and the target app.
Note: I am able to access the mamp page & also the assetlinks.json from Chrome on Android emulator.
Am I missing something here or is it not possible to test this in local environment?

Deeplink not work for some messaging app in Android

I am developing an android app.
It uses AppsFlyer's Onelink kind of a Deeplink.
I set up and tested, in general, it works fine.
When I tested this using Android studio, it works fine
When I tested this with Slack messenger, it works fine too.
But If I test this with other messaging apps, it doesn't work, and just open the web browser.
I don't know why and how to fix it.
<intent-filter
android:autoVerify="true"
android:label="#string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="mylink.com"
android:pathPrefix="/path"
android:scheme="https" />
</intent-filter>
For deep linking to work in Android 12, you need to create intent-filters with autoVerify="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:scheme="https" />
<data android:scheme="https" />
<data android:host="www.example.com" />
<data android:host="mobile.example.com" />
</intent-filter>
Host a Digital Asset Links JSON on your website at the below location to declare the association between your intent filters and the website.
https://your-domain.name/.well-known/assetlinks.json
assertlinks.json should contain the following information
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "your.app.package.name",
"sha256_cert_fingerprints": ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"]
}
}]
You can generate sha256_cert_fingerprints using java key tool
keytool -list -v -keystore my-release-key.keystore
If you're using Play App Signing, You can find Digital Asset Links JSON snippet at the following location Release > Setup > App Integrity

Categories

Resources