Build app indexing: deep links, deferred deep links, verify.
- User
Build app indexing: deep links, deferred deep links, verify.
Assistant
Build app indexing: deep links, deferred deep links, verify.
The user wants to know how to build app indexing, specifically focusing on deep links, deferred deep links, and verification.
1. Understand the Goal: The user wants a guide or explanation on implementing App Indexing (often called Universal Links on iOS and App Links on Android). The core components requested are:
2. Structure the Response: A logical flow would be platform-agnostic first (concepts), then platform-specific implementation details (iOS vs. Android), followed by deferred deep linking specifics, and finally verification/testing.
assetlinks.json for Android.apple-app-site-association for iOS.3. Drafting Content - Platform by Platform:
Android (App Links):
AndroidManifest.xml.https (preferred) or custom scheme (myapp://)./.well-known/assetlinks.json. Tools: Digital Asset Links.iOS (Universal Links):
/.well-known/apple-app-site-association (no file extension).sharedWebCredential but that's deprecated/restricted. Now mostly relies on:
4. Refining the "Deferred Deep Linking" section: This is often the most confusing part.
InstallReferrer API. The Play Store passes the referrer string to the app on first launch.5. Refining the "Verification" section: This is crucial for "Universal Links" (iOS) and "App Links" (Android) so the OS doesn't ask "Open with Chrome or App?".
assetlinks.json. Needs SHA256 fingerprint of signing key.apple-app-site-association. Needs Team ID and Bundle ID. No file extension. JSON structure.6. Organizing the Guide:
7. Self-Correction/Review during drafting:
8. Final Polish of the content: Make sure code snippets are accurate.
<intent-filter> with autoVerify="true".applinks:example.com.Let's write the response based on this structure. I will provide a comprehensive technical guide covering both iOS and Android.
NSUserActivity in AppDelegate/SceneDelegate.Let's start writing.
(Self-Correction on iOS Deferred Linking):
There is a specific mechanism for iOS called Shared Web Credentials but that's for passwords.
For deferred links, the only native-ish way is if the user comes from an Apple Search Ad. The NSUserActivity contains attribution info. For general web links (e.g., a Facebook ad), native deferred deep linking is effectively impossible without fingerprinting. I must clarify this limitation.
Let's stick to a clean, step-by-step implementation guide.
Step 1: Android Implementation
assetlinks.json (SHA256 keys).Step 2: iOS Implementation
apple-app-site-association.continue userActivity.Step 3: Deferred Deep Links (The specific request)
Step 4: Verification
This looks solid. I will generate the response now. To implement App Indexing with support for deep links, deferred deep links, and verification, you need to configure both your native code (Android/iOS) and your website. This allows search engines to crawl your app content and users to open your app directly from search results or links.
Here is a comprehensive technical guide.
Standard deep links open specific content within your app when a user clicks a URL (e.g., https://example.com/product/123).
Android uses App Links (based on HTTP URLs) to verify ownership of your domain.
1. AndroidManifest.xml Configuration
Add an intent-filter to the Activity that should handle the links. The autoVerify="true" attribute is crucial for bypassing the "Open with" dialog.
<activity android:name=".MainActivity">
<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" />
<!-- Handles URLs starting with "https://www.example.com" -->
<data android:scheme="https" android:host="www.example.com" />
</intent-filter>
</activity>
2. Handling the Link In your Activity, retrieve the URL data:
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) {
val productId = appLinkData.lastPathSegment // e.g., "123"
navigateToProduct(productId)
}
}
iOS uses Universal Links. Unlike custom URI schemes (myapp://), these are standard HTTPS links.
1. Enable Capability In Xcode:
applinks:www.example.com.2. Handling the Link
In your AppDelegate.swift (or SceneDelegate.swift for iOS 13+), implement the handler:
import UIKit
// For iOS 13+ (SceneDelegate)
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL else { return }
// Parse the URL components
let components = URLComponents(url: url, resolvingAgainstBaseURL: true)
// Logic to navigate user based on URL path
print("Received Universal Link: \(url)")
}
// For older iOS versions (AppDelegate)
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// Same logic as above
return true
}
To prevent malicious apps from hijacking your URLs, both platforms require you to host a verification file on your website. This file must be served over HTTPS.
assetlinks.jsonkeytool -list -v -keystore my-release-key.keystore
assetlinks.json using the SHA-256 fingerprint.
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.example.app",
"sha256_cert_fingerprints": ["14:6D:E9:83:C5:...:CE:3D"]
}
}]
https://example.com/.well-known/assetlinks.json.apple-app-site-associationNote: iOS 13+ prefers the format below.
apple-app-site-association (no file extension).
{
"applinks": {
"details": [
{
"appIDs": [ "TEAMID.com.example.app" ],
"components": [
{
"/": "/product/*",
"comment": "Matches any product URL"
}
]
}
]
}
}
(Replace TEAMID with your Apple Developer Team ID).https://example.com/.well-known/apple-app-site-association or https://example.com/apple-app-site-association.Content-Type: application/json.A Deferred Deep Link works when a user clicks a link (e.g., in an ad or email) but doesn't have the app installed.
There is no 100% reliable native "one-click" API for this on both platforms due to privacy sandbox restrictions. The industry standards are:
Method A: Use a Third-Party Service (Recommended) Services like Branch.io, Adjust, AppsFlyer, or Firebase Dynamic Links (deprecated, but alternatives exist) use fingerprinting and ID matching to handle this.
Method B: Google Play Install Referrer (Android Only)
You can pass a referrer parameter in the Google Play Store URL.
https://play.google.com/store/apps/details?id=com.example.app&referrer=product_id_123product_id_123 on first launch.Method C: Pasteboard / Clipboard (iOS - User Interaction Required) Due to iOS privacy (ATT), deferred deep linking is difficult.
Method D: Smart App Banners (iOS Web -> App)
While not strictly deferred linking, placing this tag in your website <head> prompts the user to open the app or install it, passing the context automatically if the app is installed:
<meta name="apple-itunes-app" content="app-id=123456789, app-argument=https://example.com/product/123">
Android Verification Testing: Use the Digital Asset Links testing tool or adb:
# Check if verification succeeded
adb shell dumpsys package d
Look for Domain Verification Status for your package name. It should say verified.
iOS Verification Testing:
https://example.com/product/123.