iOS
Universal Links
in-app navigation
troubleshooting
app development

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.

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.

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:

  1. 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.
  2. 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".
  3. 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.

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.
  • 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.
  • Confirm that the web page corresponding to the link is accessible and correctly configured.
FeatureUniversal LinksCustom URL Schemes
Introduced iniOS 9iOS 2
Platform FlexibilityOnly opens the app if installed Otherwise, opens in SafariOnly attempts to open the app; fails if not installed
SecurityMore secure with domain associationLess secure; any app can claim a URL scheme
MaintenanceRequires server configurationNo server-side requirements
Handling Multiple AppsCan handle links by multiple apps intelligentlySimple, static link association
  • 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.


Course illustration
Course illustration

All Rights Reserved.