Android App Link - Testing the flow in local environment - android

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?

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.

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

You should have at least one active APK that is mapped to site 'sample.com' via a web 'intent-filter'

Trying to upload instant application but getting this error
You should have at least one active APK that is mapped to site 'sample.com' via a web 'intent-filter'.
<activity
android:name=".ui.InstantSplash"
android:screenOrientation="portrait"
android:theme="#style/splashScreenTheme">
<meta-data
android:name="default-url"
android:value="https://sample.com/base-app/salt_one" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter
android:autoVerify="true"
tools:targetApi="m">
<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="sample.com" />
<data android:pathPrefix="/base-app" />
<data android:scheme="https" />
</intent-filter>
</activity>
Upload installable APK in alpha, beta or production with same HOST web 'intent-filter'.
You are defining an Intent filter with the scheme and host:
<data android:scheme="http" />
<data android:host="sample.com" />
so you have to access your deep links with
http://sample.com
but this domain must be a valid domain, and this domain must be of your property because you need to add the assetlinks.json
The website www.example.com publishes a statement list at
https://www.example.com/.well-known/assetlinks.json. This is the
official name and location for a statement list on a site; statement
lists in any other location, or with any other name, are not valid for
this site. In our example, the statement list consists of one
statement, granting its Android app the permission to open links on
its site:
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target" : { "namespace": "android_app", "package_name": "com.example.app",
"sha256_cert_fingerprints": ["hash_of_app_certificate"] }
}]
Read more about it:
https://developers.google.com/digital-asset-links/v1/getting-started#quick-usage-example
Instant apps does not support HTTP. Your default-url should be HTTPS
<meta-data
android:name="default-url"
android:value="https://sample.com/base-app/salt_one" />
Your app must also define a default URL for your app. Within the same Android manifest as your entry-point activity, you define the default URL for your app by adding a element with a value attribute that provides a valid HTTPS URL that the activity can handle. Further, this default url must also be part of the CATEGORY_LAUNCHER activity's intent filter in the installed app.
The following code snippet shows an Android manifest that defines an entry-point activity and default URL for an instant app.
<activity
android:name=".MainActivity">
<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:scheme="https" />
<data android:host="example.com" />
</intent-filter>
<meta-data
android:name="default-url"
android:value="https://www.example.com/index.html" />
</activity>
Instant apps does not support HTTP. Your default-url should be HTTPS
For more details can you check android AIA documentation.
There is some inappropriate string for error message, can you ensure fix with, installable APK in alpha, beta or production with same HOST web 'intent-filter'.

Linking app through Digital Asset Link protocol

My problem is that uploading my signed APK for my android instant app to google play console gives me the following error:
Your site 'anam-instant.mybluemix.net' has not been linked through the Digital Assets Link protocol to your app. Please link your site through the Digital Assets Link protocol to your app.
I have a single base module, with the AndroidManifest.xml intent filter as follows:
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter
android:autoVerify="true"
android:order="1" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="https" />
<data android:scheme="http" />
<data android:host="MYURL.net" />
<data android:pathPrefix="/hello" />
</intent-filter>
<meta-data
android:name="default-url"
android:value="https://MYURL.net/hello"/>
At /.well-known/assetlinks.json
[
{
relation: [
"delegate_permission/common.handle_all_urls"
],
target: {
namespace: "android_app",
package_name: "com.example.anam.my_instantapp",
sha256_cert_fingerprints: ["SHA256-CERT"]
}
}
]
I have Google app signing enabled and got my sha256 cert from there, using the Upload certificate.
I have verified that the package name is the same as the package name in the base module's AndroidManifest.xml.
I have verified that my robots.txt allows all.
I'm trying to release this under Instant app development.

Deep-linking implementation in Android

I am implementing Deep-linking in my android application. I have added the properties mentioned here but still I am not getting any logs while debugging neither its working for my application.
My manifest is looking like:
<activity
android:name=".activities.HomeActivity"
android:configChanges="orientation|screenSize"
android:exported="true"
android:label="#string/app_name"
android:launchMode="singleInstance"
android:noHistory="false"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter android:autoVerify="true">
<data android:host="domain" android:scheme="https" />
<data android:host="domain" android:scheme="http" />
<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 am testing on a device having api level 23. But still its not working. Any help will be really appreciated.
I have placed following file on my server:
I have created a directory named ".well-known" and then saved the file having content given below with name "assetlinks.json"
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target" : { "namespace": "android_app",
"package_name": "package-name",
"sha256_cert_fingerprints": ["fingerprints"] }
}]
But still neither getting any logs, nor its working.

Categories

Resources