Design app indexing and deep linking: iOS/Android setup, Firebase, and parity…
- User
Design app indexing and deep linking: iOS/Android setup, Firebase, and parity verification.
Assistant
Design app indexing and deep linking: iOS/Android setup, Firebase, and parity verification.
The user wants a guide on designing App Indexing and Deep Linking. The scope covers:
Structure of the Response:
Introduction: Define Deep Linking vs. App Indexing.
myapp://).https://www.example.com).Architecture Overview:
Part 1: Android Setup (App Links):
intent-filter with autoVerify.Part 2: iOS Setup (Universal Links):
applinks:www.example.com)..well-known.Part 3: Firebase Integration (The "Indexing" part & Legacy handling):
FirebaseAppIndexing library is largely obsolete, and the focus is on the OS mechanism + Search Console.Part 4: Parity Verification (Testing & QA):
Summary/Checklist: A quick reference table.
Drafting the Content - Key Technical Details:
/.well-known/assetlinks.json. Use "App Links Assistant" in Android Studio./.well-known/apple-app-site-association. JSON structure (no file extension, specific content-type).Refining the "Parity Verification" Section: How do we test this?
https://host/path?param=value -> Map to Screen A.adb shell dumpsys package d (to check auto-verification status).Self-Correction during drafting: The user asked for "Design... Firebase". If I just say "Don't use Firebase for links," I might be ignoring a specific requirement if they are stuck with legacy code or specifically want to use the remaining Firebase services (like hosting the AASA file). I will frame it as: "Use Firebase Hosting to serve the verification files" and "Use Firebase Analytics to track link performance."
Structure Plan:
Let's write it. This guide outlines the architecture and implementation for a robust deep linking strategy.
Critical Context: Firebase Dynamic Links (FDL) is deprecated. Do not use it for new projects. This guide uses the modern standard: OS-level Universal Links (iOS) and App Links (Android), supplemented by Firebase Hosting for URL parity and Google Search Console for Indexing.
To achieve parity, we treat the web as the source of truth.
https://your-domain.com/path/to/contentUniversal Links require a handshake between your website and Apple.
A. Apple Developer Portal
applinks:your-domain.com (do not include https://).B. The apple-app-site-association (AASA) File
Host a JSON file at https://your-domain.com/.well-known/apple-app-site-association. No file extension.
{
"applinks": {
"details": [
{
"appID": "<TEAM_ID>.<BUNDLE_ID>",
"paths": ["*"]
// Best Practice: Be specific, e.g., "/product/*", "/user/*"
// Exclude paths like "/blog/*" if you want those to open in web.
}
]
}
}
application/json.C. Xcode Configuration
applinks:your-domain.com.D. Handling the Link (Swift)
In your AppDelegate or SceneDelegate:
// SceneDelegate (iOS 13+)
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL else { return }
// Parse the URL path and navigate
handleDeepLink(url: url)
}
Android uses Digital Asset Links to verify ownership.
A. The assetlinks.json File
Host this at https://your-domain.com/.well-known/assetlinks.json.
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.yourcompany.app",
"sha256_cert_fingerprints": [
"GET_THIS_FROM_YOUR_SIGNING_KEY"
// Note: Use Release key fingerprint for Production!
]
}
}
]
keytool -list -v -keystore my-release-key.keystore.B. Android Manifest (AndroidManifest.xml)
Add an intent-filter to your main activity (or the specific activity handling the link).
<activity android:name=".MainActivity">
<!-- HTTP/HTTPS scheme -->
<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" />
<!-- Accepts URIs that begin with "https://your-domain.com" -->
<data android:scheme="https" android:host="your-domain.com" />
</intent-filter>
</activity>
android:autoVerify="true" is critical. It tells Android to check your website immediately after install to skip the "Open with" dialog.C. Handling the Link (Kotlin) In your Activity:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// ...
val appLinkIntent = intent
val appLinkAction = appLinkIntent?.action
val appLinkData = appLinkIntent?.data
if (Intent.ACTION_VIEW == appLinkAction && appLinkData != null) {
handleDeepLink(appLinkData)
}
}
Since Dynamic Links is dead, use Firebase Hosting to serve the .well-known files and manage redirects. This simplifies SSL and parity verification.
Setup Steps:
npm install -g firebase-tools.firebase init hosting.firebase.json:{
"hosting": {
"public": "public",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
// If the user hits a deep link path on desktop or web, serve your web app.
// If they hit it on mobile, the OS intercepts it before hitting this.
{
"source": "/product/**",
"destination": "/product-detail.html"
}
],
"cleanUrls": true
}
}
Why use Firebase Hosting?
assetlinks.json and apple-app-site-association files are served with the correct headers and SSL (required by Apple/Google).To ensure "Parity," your app and web routes must match 1:1.
Create a single Deep Link Handler in your codebase.
| URL | Screen (App) | Page (Web) | Action |
|---|---|---|---|
host.com/user/123 | ProfileViewController | /user/profile | Load User ID 123 |
host.com/settings | SettingsFragment | /settings | Open Settings Tab |
Verification Checklist:
host.com/x exist on Web? Does host.com/x route to Screen X in App??id=1 vs App uses ?id=1. Ensure the parser handles Query Params and Path Params (/id/1).swcutil). Or use third-party tools like Branch Explorer.To get your app content to appear in Google Search results (App Indexing):
your-domain.com) in Google Search Console.assetlinks.json is valid. Google crawlers will check this file to associate the website with the app./.well-known/assetlinks.json (Android) and /.well-known/apple-app-site-association (iOS) via Firebase Hosting.autoVerify=true intent filter in Manifest.https:// URLs on both platforms.