Hello everyone ,
We are going to create deep links for our app.
Deep link
When a clicked link or programmatic request invokes a web URI intent, the Android system tries each of the following actions, in sequential order, until the request succeeds:
- Open the user’s preferred app that can handle the URI, if one is designated.
- Open the only available app that can handle the URI.
- Allow the user to select an app from a dialog
This is taken from Android documentation
Create a new project
In Designer
- Add your package name e.g. com.thesocial.bus
- Upload intent-filters.txt in Assets
intent-filters.txt (464 Bytes)
Inside intent-filters.txt
<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="www.thesocialbus.com"/>
// To accept more domain or subdomain. Just add a new data element
// <data android:host="www.example.com"/>
</intent-filter>
Basic information about above code
-
autoVerify - When `it’s true and present in your app’s intent filters, installing your app on a device that runs Android 6.0 (API level 23) or higher causes the system to automatically verify the hosts associated with the URLs in your app’s intent filters
-
scheme - You can add http, https and any custom text e.g. app.
-
host - You can add the domain which you want to verify e.g. www.thesocialbus.com
This is going to be added in your app’s AndroidManifest.xml (Screen1). So, Android will always open our app whenever https://www.thesocialbus.com or http://www.thesocialbus.com is clicked.
In Blocks
We have to use this block to get which url is clicked and redirected to your app. It is available in Screen’s properties.
Complete blocks
Now, build your project once to get SHA-256 fingerprint generated.
Creating a deep link
Requirements
To create a deep link, You need :
- A website’s link (We will use www.thesocialbus.com). Thanks to @Jay for his website.
- A
assetlinks.json
file which must be uploaded at
https://domain.name/.well-known/assetlinks.json
Generating assetlinks.json file
It is required for auto verifying your domain in devices above Android 12.
Visit this site and generate the assetlinks.json file.
-
Hosting site domain - Enter your domain name e.g. www.thesocialbus.com
-
App package name - Enter app’s package name e.g. com.thesocialbus
-
App package fingerprint (SHA256) - Get it from Appzard workspace
Click on Profile icon
Click on Keystore Information
Copy SHA-256 fingerprint
After generating the statement list. Copy the generated statement and paste in assetlinks.json. Now, upload it at
https://domain.name/.well-known/assetlinks.json
Building your project (APK)
Hurray ! You have successfully added deep links in your project. Build your project and test it.
Testing
Tested on Android 12 and Android 9. working good for me
Auto verify works too
FAQs
Q1. Why SHA-256 fingerprint is not visible ?
Ans. To generate SHA-256, you need to build the apk once
Q2. How can we accept all subdomains ?
Ans. If you want to accept all subdomains you have to use an asterisk (*) character before your host like this: *.example.com.
Q3. My domain don’t have www or any subdomain ? What to do ?
Ans. Add host without subdomain like this
<data android:host="example.com"/>
I tested it. And I was able to open my app but no start data was there.
Download links
Project file - Deeplink.aia (8.8 KB)
Test APK - Click me to download
Thanks
Reply to this topic if you have any query