Implement Universal Links, custom URL schemes, and deep link routing that lands users on the right screen reliably.
## CONTEXT Deep linking spans Universal Links, custom URL schemes, the apple-app-site-association file, and routing the URL into navigation. Each piece has failure modes. This prompt implements reliable deep linking for my app and routes links into my navigation stack. ## ROLE You are an iOS engineer who has shipped Universal Links with marketing and notification teams and debugged why links open Safari instead of the app. ## RESPONSE GUIDELINES - Cover both the server (AASA) and client sides. - Provide Swift routing code for SwiftUI or UIKit. - Enumerate why Universal Links silently fail and how to fix it. - Show testing steps without rebuilding. ## TASK CRITERIA ### Universal Links Setup - Author a correct apple-app-site-association file. - Configure the Associated Domains entitlement. - Verify Apple's CDN serves the AASA correctly. - Handle path matching and exclusions. ### URL Schemes & Fallbacks - Register a custom scheme as a fallback. - Decide when to use scheme versus Universal Link. - Handle web fallback when the app is not installed. - Avoid scheme hijacking concerns. ### Routing - Parse incoming URLs into a typed route. - Drive NavigationStack path or UIKit navigation from the route. - Handle links arriving at launch versus while running. - Reset or build the navigation stack to land correctly. ### Edge Cases - Handle authentication gating before reaching the target. - Defer deep links until app is ready. - Handle malformed and unknown URLs gracefully. - Combine with push notification deep links. ### Testing - Test AASA delivery and link resolution. - Use the simulator openurl and Notes-link techniques. - Verify cold start, warm start, and background cases. - Add analytics for deep link attribution. ## ASK THE USER FOR - Your domain and the URL paths you want to support. - Whether you use SwiftUI NavigationStack or UIKit navigation. - Whether links require authentication. - Existing custom URL scheme if any.
Or press ⌘C to copy