Android App Links on Android 12 - `legacy_failure` - android

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.

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.

Using external deeplinks to open android app, opens chrome with 403 message

I've followed the docs for adding deeplink where we use
https://mydomain.co/app or https://mydomain.co/app/details, etc to navigate to the app. So I've updated the manifest for this:
<intent-filter android:autoVerify="true">
<data
android:host="mydomain.co"
android:pathPrefix="/app"
android:scheme="https" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Generated the Digital Asset Links json file and added to the domain https://mydomain.co/.well-known/assetlinks.json
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "co.myapp.app",
"sha256_cert_fingerprints":
["redacted:key"]
}
}
]
So when I test using adb command (ex. adb shell am start -d "https://mydomain.co/app/profile/edit_profile")
it works perfectly but when I try using the link externally, it opens chrome and gives me 403. I'm not sure what I'm missing or what's wrong. Can somebody help me? Thanks in advance!
I found the solution: The main issue was the signature keys were not matching between Google Play and the release. That's because Google adds its own that can't be shared. So the only way to make it work was to upload the app in the Google Play Store. That means to make it work locally I need to add the signature key for the debug build into the Digital Asset Links json file.

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?

Android: Deep linking web urls

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

Deep Linking from browser not working Android

Deep Linking not working in android. I have pasted my manifest code here. When I tested, it goes to the website and not opening my activity in my app. Can someone help me fix this?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.clinicloud.app" >
<application
android:name=".MainApp"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<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:host="www.XXXX.com"
android:pathPrefix="/xyz"
android:scheme="http"/>
</intent-filter>
</activity>
<activity
android:name=".OnboardingActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ProfileViewActivity"
android:label="#string/title_activity_profile_view"
android:theme="#style/AppTheme.NoActionBar" >
</activity>
</application>
</manifest>
UPDATE:
adb shell am start -W -a android.intent.action.VIEW -d "http://www.clinicloud.com/xyz" com.clinicloud.app
Testing with adb opens the app but just with browser its not opening the app.
It's so annoying to test deep link through adb as the Android Developer team suggested. We won't get the gist of the problem I think. We want a straight forward method like paste a link to the browser in the same device which also installed the app already, hit GO, then the app comes up. But unfortunately, it won't work though.
Reason:
It's not a pure link, when you go to URL search of the browser it actually does a different URL, e.g: 'https://www.google.com/search?....'
Solution: Open a pure link
As #Parag Chauhan suggested, using another app to open a link, sure it is a definitely working solution because it's a pure link. However, this is not practical as expected.
Alternatively,
2.1. You can build your own simple web page (simple file *.html) with a link, then click it to open a pure link. Here is an example of the web page:
<html>
<h1>
<a id="deeplink" href="ss.wohui.learn://subscribed">Deep Link</a>
</h1>
</html>
2.2. Replace ss.wohui.learn://subscribed with what your deep link is.
2.3. Download the file to your device.
2.4. Open it by a browser.
2.5. Click on the Deep Link.
2.6. The app will start.
Add this code in Manifest.xml
<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:host="www.clinicloud.com"
android:path="/xyz"
android:scheme="http" />
</intent-filter>
For test create another project and run below code
Intent i = new Intent(
Intent.ACTION_VIEW , Uri.parse("http://www.clinicloud.com/xyz")
);
startActivity(i);
You can also pass parameter in link. For more info, see my blog post Make a link in the Android browser start up my app?
This will only work if server has /.well-known/assetlinks.json properly defined in the root domain on the server.
So you need to create a json file and define there package name and SHA256. Then guys from backend should put this json file into root domain on the server.
The content of the file looks like:
[
{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "com.blablabla.staging",
"sha256_cert_fingerprints": ["XXXXXXXXXXXXXXXXXXX"]
}
}
]
You can split it for different environments: staging, beta, prod etc.
I tested in default browser of Samsung “Internet” and it fired the deeplink!

Categories

Resources