iOS Universal Links are not opening in-app
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Understanding Why iOS Universal Links Are Not Opening In-App
Universal Links are a crucial feature in iOS that allow apps to seamlessly handle web and app content. When a user taps a Universal Link, iOS can open the associated app instead of the Safari browser if the app is installed. However, several factors can prevent Universal Links from functioning correctly. This article dives into the technical aspects of Universal Links and provides solutions to common problems.
How Universal Links Work
Apple introduced Universal Links in iOS 9 as a replacement for URL schemes offering more secure and flexible link handling. Here's a breakdown of their functioning process:
- Association with the App:
- Developers need to associate Universal Links with their app using the `apple-app-site-association` (AASA) file.
- This JSON file must be hosted on the server of the domain they wish to link to the app.
- The file specifies the paths that the app can handle.
- Entitlements and App Capabilities:
- Apps must include an entitlement called `com.apple.developer.associated-domains` that lists associated domains.
- In Xcode, this is managed under the "Capabilities" tab by enabling "Associated Domains".
- User Interaction & System Handling:
- When a link is tapped, iOS checks the AASA file for the app association.
- If the app is installed and correctly associated, iOS will open the link within the app.
- If the app is not installed, the link opens in Safari.
Common Problems with Universal Links
1. App Not Opening
If Universal Links are not opening the app, consider troubleshooting the following areas:
- AASA File Issues:
- The AASA file might not be correctly served. Ensure it's accessible via the correct URL: `https://``<your-domain>``/.well-known/apple-app-site-association`.
- Verify the file's content and MIME type (`application/json`).
- Missing Entitlements:
- Ensure that the app’s entitlements include the correct domain and have this feature enabled.
- Incorrect Link Handling:
- The `application:continueUserActivity:restorationHandler:` method in the AppDelegate may not handle the URL paths correctly.
2. Link Opens in Safari
- Check for any redirects in the link. Universal Links do not handle redirects well and may defer to Safari.
- Cached results may bypass the app association. Restart the device and clear browsing data to test anew.
3. App is Not Installed But Link Opens in Safari
- Confirm that the web page corresponding to the link is accessible and correctly configured.
Comparison: Universal Links vs. Custom URL Schemes
| Feature | Universal Links | Custom URL Schemes |
| Introduced in | iOS 9 | iOS 2 |
| Platform Flexibility | Only opens the app if installed Otherwise, opens in Safari | Only attempts to open the app; fails if not installed |
| Security | More secure with domain association | Less secure; any app can claim a URL scheme |
| Maintenance | Requires server configuration | No server-side requirements |
| Handling Multiple Apps | Can handle links by multiple apps intelligently | Simple, static link association |
Best Practices for Implementing Universal Links
- Test Extensively: Always test Universal Links in various scenarios, including uninstalled app cases.
- Fallback Logic: Implement a fallback mechanism so users can reach content even if the app fails to open.
- Clear Protocols: Ensure clarity in protocols, offering clear user instructions for installation if a link fails.
- Regular Updates: Keep the AASA file and app entitlements updated, especially after domain changes.
Conclusion
Universal Links are a powerful tool that, when implemented correctly, enhance user experience by bridging web and app content. By understanding their structure and following best practices, developers can resolve common pitfalls and ensure smooth navigation for their users. Regular testing and updates play a pivotal role in maintaining robust Universal Link functionality.

