Implementing Custom URL Scheme for Mobile Application
Deep link doesn't open—user sees empty browser instead of needed app screen. Or opens, but passes parameters in encoding the app doesn't parse. Classic on first URL scheme implementation.
Two Approaches and When to Choose
Custom URL Scheme (myapp://product/123) — simple to implement, but insecure: any app can register same scheme and intercept deeplink. Suitable for internal navigation between own apps or dev tools.
Universal Links (iOS) / App Links (Android) — work via HTTPS domain with verification file (apple-app-site-association / assetlinks.json). Secure, fall back to browser if app not installed. This is right path for production.
Practically, implement both: Universal Links as main mechanism, Custom URL Scheme as fallback when domain verification impossible.
Implementation Details
iOS (Swift/SwiftUI): register scheme in Info.plist under CFBundleURLTypes, handle in application(_:open:options:) for UIKit or via .onOpenURL in SwiftUI. For Universal Links—application(_:continue:restorationHandler:). Parse URL via URLComponents, not manual string split.
Android (Kotlin): add <intent-filter> with <data android:scheme="myapp"/> in AndroidManifest.xml, handle intent.data in Activity. For App Links add android:autoVerify="true" and load assetlinks.json at https://domain.com/.well-known/.
React Native: use Linking API from react-native core, for navigation—@react-navigation/native with linking config. Main mistake—forget to handle when app was closed (cold start) vs already running (foreground). These are different events.
Flutter: go_router package supports deep links natively, just configure routerConfig with GoRouter and add config to native modules via flutter_deeplinking_enabled in Info.plist/manifest.
Typical Testing Error
Test deeplinks only via Safari/Chrome, forget to check "app installed but closed" case. On iOS with Universal Links sometimes delay in AASA file verification at first launch—app opens via browser instead of deeplink, team thinks something broken. Normal behavior, cache updates within day.
Timeline: 1-3 days for basic Custom URL Scheme, up to 5 days if need Universal Links with domain setup and navigation to specific screens.







