Steps to Implement Deep Link (2 + App Links) for Your New App
Since I already have one app on Play Store with deep link (App Links), adding another app with its own deep links requires a few careful steps.
1. Create new Digital Asset Links file (assetlinks.json
)
Every app must have its own package name and SHA256 certificate fingerprints in the assetlinks.json
.
For your new app (let’s say package_name = com.yourorg.newapp
):
[
{
“relation”: [“delegate_permission/common.handle_all_urls”],
“target”: {
“namespace”: “android_app”,
“package_name”: “com.yourorg.newapp”,
“sha256_cert_fingerprints”: [
“AA:BB:CC:DD:…:FF” // Replace with your new app signing certificate SHA-256
]
}
}
]
2. Host the assetlinks.json
file
- Make sure it is publicly accessible (check with browser).
- If you already have an
assetlinks.json
for the first app, you just need to add another object for the second app.
Example with two apps in same file:
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "nanoakhi.rcfinternal",
"sha256_cert_fingerprints": [
"AA:BB:CC:DD:…:FF", //this is Google play console u will get
"AA:BB:CC:DD:…:FF" //this is Android Studio u will get for debugging
]
}
},
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.yourorg.newapp",
"sha256_cert_fingerprints": [
"AA:BB:CC:DD:…:FF", //this is Google play console u will get
"AA:BB:CC:DD:…:FF" //this is Android Studio u will get for debugging
]
}
}
]
3. Update your new app’s AndroidManifest.xml
Add an intent filter to handle deep links:
<activity
android:name=".YourDeepLinkActivity"
android:exported="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" />
<!-- Change host/path according to your domain -->
<data
android:scheme="https"
android:host="yourdomain.com"
android:pathPrefix="/deeplink" />
</intent-filter>
</activity>
android:autoVerify="true"
makes Android check assetlinks.json
during install.
4. Handle the deep link in code
In your YourDeepLinkActivity
(or MainActivity):
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = getIntent();
Uri data = intent.getData();
if (data != null) {
String path = data.getPath();
String query = data.getQueryParameter("id"); // Example
Toast.makeText(this, "Deep link opened: " + path + " id=" + query, Toast.LENGTH_LONG).show();
}
}
Post a Comment
0Comments