Estimated Read Time: # Minutes
How to Test Universal Links on iOS

Learn how to test Universal Links on iOS, including setup, troubleshooting, and best practices, ensuring a seamless user experience across web and app content.

Please Enter a Valid Business Email Address
Thank you! Please find the download link here:
Oops! Something went wrong while submitting the form.

How to Test Universal Links on iOS

Estimated Read Time: # Minutes
Team Mobot
June 7, 2024

Learn how to test Universal Links on iOS, including setup, troubleshooting, and best practices, ensuring a seamless user experience across web and app content.

1. Introduction 

Universal Links are a crucial aspect of modern iOS applications, enabling seamless navigation between web content and the corresponding app content. Testing these links ensures that users have a smooth and integrated experience, whether they are opening a link from Safari, Messages, or another app. Proper testing can prevent issues such as links opening in Safari instead of your app or failing altogether.

‍

2. Understanding Universal Links

What are Universal Links?

Universal Links are a technology introduced by Apple to replace the older URL scheme method for deep linking. Unlike URL schemes, Universal Links are standard HTTPS links that can seamlessly open an app if it's installed or fall back to a website if the app is not installed. This provides a more cohesive user experience and leverages existing web URLs.

For example, if your website is example.com, a Universal Link might look like https://example.com/path/to/content. When a user taps this link, iOS determines whether to open the content in your app or the web browser based on the presence of your app and the configuration of Universal Links.

How Universal Links Work on iOS

When a user taps a Universal Link, iOS performs several checks to determine the appropriate action:

  1. App Installed: If the app associated with the link is installed, iOS checks if the app can handle the link. This involves verifying the Apple App Site Association (AASA) file hosted on your domain.
  2. AASA File: The AASA file is a JSON file hosted at https://example.com/apple-app-site-association. This file specifies which paths on your domain should be handled by your app.
  3. Link Handling: If the app can handle the link, it opens the app and passes the link's path to the app. If the app is not installed, iOS opens the link in Safari.

Here’s an example of an AASA file:

In this example, the AASA file indicates that links matching /path/to/content/* and /another/path/* should open in the app with the appID ABCDE12345.com.example.app.

By understanding the mechanics of Universal Links, you can ensure that your app and web infrastructure are correctly configured to support them. Next, we'll move on to setting up Universal Links in your app and verifying the configuration.

3. Setting Up Universal Links

Setting up Universal Links involves a few critical steps, including configuring the Apple App Site Association (AASA) file, adding associated domains in Xcode, and verifying the AASA file deployment. 

Configuring the Apple App Site Association (AASA) File

The AASA file is a JSON file hosted on your server that tells iOS which URLs should open in your app. Here’s how to configure it:

  1. Create the AASA File: Create a JSON file named apple-app-site-association with the following structure:

Json

  • appID: The App ID prefix and the bundle identifier of your app.
  • paths: The paths that should be handled by your app. Wildcards can be used for flexibility.
  1. Host the AASA File: Upload the apple-app-site-association file to the root of your website (https://example.com/apple-app-site-association).
  2. Ensure Correct MIME Type: Ensure your web server serves the AASA file with the MIME type application/json.

Adding Associated Domains in Xcode

Next, configure your Xcode project to handle the associated domains:

  1. Open Xcode and Navigate to Your Project: Open your project in Xcode and select your app target.
  2. Enable Associated Domains: Go to the "Signing & Capabilities" tab and click on the "+" button to add a new capability. Select "Associated Domains."
  3. Add Your Domains: Under the Associated Domains section, add the domains you want to associate with your app in the format applinks:example.com.

Verifying AASA File Deployment

To verify that the AASA file is correctly deployed and accessible:

  1. Access the AASA File: Open a web browser and navigate to https://example.com/apple-app-site-association. Ensure that the file is accessible and correctly formatted.
  2. Use Apple's AASA Validator: Apple provides a tool to validate your AASA file. You can use tools like Branch.io's AASA validator to ensure your file is correctly set up.

By following these steps, your Universal Links should be correctly configured, allowing iOS to open your app when a user taps on the appropriate links.

4. Testing Universal Links

Manual Testing

Manual testing involves directly interacting with Universal Links on your device to ensure they open the app as intended.

Setting Up a Local Server for Testing

If you’re developing and testing locally, you can use a tool like ngrok to expose your local server to the internet.

  1. Install and Start ngrok: Download and install ngrok, then start it by running:
  1. Update AASA File: Update your AASA file to use the ngrok URL for testing purposes.

Using Safari and Notes App for Testing Universal Links

To test Universal Links manually:

  1. Open Safari: Type a Universal Link URL in Safari. If your app is installed and configured correctly, it should open your app.
  2. Use the Notes App: Paste a Universal Link into the Notes app, long-press the link, and choose "Open in App." This helps verify the link handling.

Automated Testing

Automated testing can save time and ensure consistency in your testing process. XCUITest is a powerful tool for automated UI testing on iOS.

Setting Up Automated Tests with XCUITest

  1. Create a New UI Test Target: In Xcode, go to File > New > Target, and select "iOS UI Testing Bundle."
  2. Write a Test Case for Universal Links: Write a test case to simulate tapping a Universal Link and verifying the app opens correctly.

Swift

‍

By incorporating both manual and automated testing, you can ensure that your Universal Links are thoroughly tested and function correctly in various scenarios.

5. Common Issues and Troubleshooting

Even with careful setup, issues with Universal Links can arise. Identifying and troubleshooting these problems is essential for ensuring a seamless user experience. Here are some common issues and ways to address them.

Debugging Universal Link Issues

  1. AASA File Not Accessible: Ensure your apple-app-site-association file is hosted correctly and accessible at https://example.com/apple-app-site-association. You can verify its accessibility by opening this URL in a browser. The file should not return a 404 error and must be served with the MIME type application/json.
  2. Incorrect AASA File Format: The AASA file must be a valid JSON file. Use a JSON validator to check for any syntax errors. Tools like JSONLint can help.
  3. App Not Handling the Link: Ensure that your app is properly configured to handle the Universal Links. Double-check the associated domains in Xcode and ensure that the paths specified in the AASA file match the paths your app is set to handle.
  4. Server Configuration: Your server must be configured to serve the AASA file correctly. Verify the server configuration to ensure it is not causing any issues.

Tools and Methods for Troubleshooting

  1. Console Logs: Use Xcode’s console to log and debug Universal Link handling in your app. You can add log statements in the application:continueUserActivity:restorationHandler: method to track link handling.
  2. Universal Link Validator Tools: Use online tools like Branch.io's AASA Validator to validate your AASA file and check if it is correctly set up.
  3. Checking Associated Domains: In Xcode, ensure that the associated domains are correctly configured under the "Signing & Capabilities" tab. Any typo or incorrect domain configuration can cause Universal Links to fail.
  4. iOS Console Logs: Use macOS’s Console app to view logs from your iOS device. This can provide insights into why a Universal Link might not be working as expected.

Common Pitfalls and How to Avoid Them

  1. Using HTTP Instead of HTTPS: Universal Links require HTTPS. Ensure all URLs in the AASA file are HTTPS.
  2. Mismatched App ID: The app ID in the AASA file must match your app’s actual app ID. Double-check for any typos or mismatches.
  3. Testing on Device: Always test Universal Links on a real device rather than the simulator, as some link-handling features may behave differently.

6. Best Practices for Universal Links

To maximize the effectiveness and reliability of Universal Links, consider the following best practices.

Ensuring a Seamless User Experience

  1. Fallback URLs: Always ensure that Universal Links have a web fallback. This way, if the app is not installed, users can still access the content in their browser.
  2. User Feedback: Provide visual feedback when a Universal Link is opened in the app. This helps users understand that the link has been correctly handled by the app.
  3. Deep Linking Context: Use deep linking to preserve the context of the user’s journey. For instance, if a user opens a specific article through a Universal Link, ensure that the app navigates directly to that article rather than just opening the home screen.

Handling Edge Cases

  1. Testing Across Versions: Test Universal Links across different versions of iOS to ensure compatibility and correct handling.
  2. Analytics and Monitoring: Implement analytics to track the usage of Universal Links. This can help identify patterns and potential issues.
  3. Regular Updates: Keep the AASA file and associated domains updated with any changes to your app’s URL structure or content paths.

Monitoring and Analytics

  1. Tracking Link Performance: Use tools like Google Analytics or custom tracking solutions to monitor how Universal Links are performing. This can provide insights into user behavior and any potential issues.
  2. Error Reporting: Implement error reporting to capture any failures in handling Universal Links. This data can be invaluable for debugging and improving the link-handling process.

By following these best practices, you can ensure that your Universal Links provide a reliable and smooth experience for your users.

7. Mobot's Role in Universal Links Testing

When it comes to ensuring the reliability and accuracy of Universal Links, leveraging specialized tools and services can be invaluable. Mobot provides automated testing services that can help streamline the testing process for Universal Links on iOS, ensuring that links perform as expected across various scenarios and devices.

How Mobot Can Assist in Testing Universal Links

  1. Automated Real Device Testing: Mobot utilizes a fleet of real devices to automate the testing of Universal Links. This ensures that links are tested in real-world conditions, across different iOS versions and device models, providing comprehensive coverage.
  2. Custom Test Scenarios: With Mobot, you can set up custom test scenarios tailored to your app's specific needs. For instance, you can automate tests for different link paths, user states (logged in vs. logged out), and app configurations.
  3. Consistent and Repeatable Tests: Automated tests provide consistency and repeatability. This means you can run the same set of tests after every deployment, ensuring that new changes do not break existing functionality.
  4. Detailed Reporting and Analytics: Mobot offers detailed reports and analytics on test outcomes. These insights can help identify patterns, potential issues, and areas for improvement.

Benefits of Using Mobot for Comprehensive Testing

  1. Time Savings: Automating Universal Links testing with Mobot can save significant time compared to manual testing. This allows your QA team to focus on other critical testing tasks.
  2. Increased Test Coverage: With the ability to test on a wide range of devices and configurations, Mobot ensures that your Universal Links work correctly for all users.
  3. Early Issue Detection: Automated testing can help detect issues early in the development cycle, reducing the cost and impact of fixing bugs later on.
  4. Scalability: As your app grows, maintaining a robust testing process becomes increasingly challenging. Mobot's scalable solutions can handle increased testing demands, ensuring that your app remains reliable and performant.

By integrating Mobot into your testing strategy, you can enhance the reliability of your Universal Links and ensure a seamless user experience.

8. Conclusion 

Ensuring the seamless functionality of Universal Links on iOS is essential for providing an integrated user experience that smoothly transitions between web and app content. By meticulously configuring the Apple App Site Association file, properly setting up associated domains in Xcode, and employing both manual and automated testing methods, you can effectively troubleshoot and resolve common issues. Adopting best practices, such as using fallback URLs and maintaining deep linking context, further enhances this process. Additionally, leveraging Mobot’s automated testing services can significantly streamline and scale your testing efforts, ensuring comprehensive coverage and reliability. Implementing these strategies will not only improve the usability of your app but also enhance user satisfaction and engagement.

How to Test Universal Links on iOS

Estimated Read Time: # Minutes
Team Mobot
June 7, 2024

Learn how to test Universal Links on iOS, including setup, troubleshooting, and best practices, ensuring a seamless user experience across web and app content.

1. Introduction 

Universal Links are a crucial aspect of modern iOS applications, enabling seamless navigation between web content and the corresponding app content. Testing these links ensures that users have a smooth and integrated experience, whether they are opening a link from Safari, Messages, or another app. Proper testing can prevent issues such as links opening in Safari instead of your app or failing altogether.

‍

2. Understanding Universal Links

What are Universal Links?

Universal Links are a technology introduced by Apple to replace the older URL scheme method for deep linking. Unlike URL schemes, Universal Links are standard HTTPS links that can seamlessly open an app if it's installed or fall back to a website if the app is not installed. This provides a more cohesive user experience and leverages existing web URLs.

For example, if your website is example.com, a Universal Link might look like https://example.com/path/to/content. When a user taps this link, iOS determines whether to open the content in your app or the web browser based on the presence of your app and the configuration of Universal Links.

How Universal Links Work on iOS

When a user taps a Universal Link, iOS performs several checks to determine the appropriate action:

  1. App Installed: If the app associated with the link is installed, iOS checks if the app can handle the link. This involves verifying the Apple App Site Association (AASA) file hosted on your domain.
  2. AASA File: The AASA file is a JSON file hosted at https://example.com/apple-app-site-association. This file specifies which paths on your domain should be handled by your app.
  3. Link Handling: If the app can handle the link, it opens the app and passes the link's path to the app. If the app is not installed, iOS opens the link in Safari.

Here’s an example of an AASA file:

In this example, the AASA file indicates that links matching /path/to/content/* and /another/path/* should open in the app with the appID ABCDE12345.com.example.app.

By understanding the mechanics of Universal Links, you can ensure that your app and web infrastructure are correctly configured to support them. Next, we'll move on to setting up Universal Links in your app and verifying the configuration.

3. Setting Up Universal Links

Setting up Universal Links involves a few critical steps, including configuring the Apple App Site Association (AASA) file, adding associated domains in Xcode, and verifying the AASA file deployment. 

Configuring the Apple App Site Association (AASA) File

The AASA file is a JSON file hosted on your server that tells iOS which URLs should open in your app. Here’s how to configure it:

  1. Create the AASA File: Create a JSON file named apple-app-site-association with the following structure:

Json

  • appID: The App ID prefix and the bundle identifier of your app.
  • paths: The paths that should be handled by your app. Wildcards can be used for flexibility.
  1. Host the AASA File: Upload the apple-app-site-association file to the root of your website (https://example.com/apple-app-site-association).
  2. Ensure Correct MIME Type: Ensure your web server serves the AASA file with the MIME type application/json.

Adding Associated Domains in Xcode

Next, configure your Xcode project to handle the associated domains:

  1. Open Xcode and Navigate to Your Project: Open your project in Xcode and select your app target.
  2. Enable Associated Domains: Go to the "Signing & Capabilities" tab and click on the "+" button to add a new capability. Select "Associated Domains."
  3. Add Your Domains: Under the Associated Domains section, add the domains you want to associate with your app in the format applinks:example.com.

Verifying AASA File Deployment

To verify that the AASA file is correctly deployed and accessible:

  1. Access the AASA File: Open a web browser and navigate to https://example.com/apple-app-site-association. Ensure that the file is accessible and correctly formatted.
  2. Use Apple's AASA Validator: Apple provides a tool to validate your AASA file. You can use tools like Branch.io's AASA validator to ensure your file is correctly set up.

By following these steps, your Universal Links should be correctly configured, allowing iOS to open your app when a user taps on the appropriate links.

4. Testing Universal Links

Manual Testing

Manual testing involves directly interacting with Universal Links on your device to ensure they open the app as intended.

Setting Up a Local Server for Testing

If you’re developing and testing locally, you can use a tool like ngrok to expose your local server to the internet.

  1. Install and Start ngrok: Download and install ngrok, then start it by running:
  1. Update AASA File: Update your AASA file to use the ngrok URL for testing purposes.

Using Safari and Notes App for Testing Universal Links

To test Universal Links manually:

  1. Open Safari: Type a Universal Link URL in Safari. If your app is installed and configured correctly, it should open your app.
  2. Use the Notes App: Paste a Universal Link into the Notes app, long-press the link, and choose "Open in App." This helps verify the link handling.

Automated Testing

Automated testing can save time and ensure consistency in your testing process. XCUITest is a powerful tool for automated UI testing on iOS.

Setting Up Automated Tests with XCUITest

  1. Create a New UI Test Target: In Xcode, go to File > New > Target, and select "iOS UI Testing Bundle."
  2. Write a Test Case for Universal Links: Write a test case to simulate tapping a Universal Link and verifying the app opens correctly.

Swift

‍

By incorporating both manual and automated testing, you can ensure that your Universal Links are thoroughly tested and function correctly in various scenarios.

5. Common Issues and Troubleshooting

Even with careful setup, issues with Universal Links can arise. Identifying and troubleshooting these problems is essential for ensuring a seamless user experience. Here are some common issues and ways to address them.

Debugging Universal Link Issues

  1. AASA File Not Accessible: Ensure your apple-app-site-association file is hosted correctly and accessible at https://example.com/apple-app-site-association. You can verify its accessibility by opening this URL in a browser. The file should not return a 404 error and must be served with the MIME type application/json.
  2. Incorrect AASA File Format: The AASA file must be a valid JSON file. Use a JSON validator to check for any syntax errors. Tools like JSONLint can help.
  3. App Not Handling the Link: Ensure that your app is properly configured to handle the Universal Links. Double-check the associated domains in Xcode and ensure that the paths specified in the AASA file match the paths your app is set to handle.
  4. Server Configuration: Your server must be configured to serve the AASA file correctly. Verify the server configuration to ensure it is not causing any issues.

Tools and Methods for Troubleshooting

  1. Console Logs: Use Xcode’s console to log and debug Universal Link handling in your app. You can add log statements in the application:continueUserActivity:restorationHandler: method to track link handling.
  2. Universal Link Validator Tools: Use online tools like Branch.io's AASA Validator to validate your AASA file and check if it is correctly set up.
  3. Checking Associated Domains: In Xcode, ensure that the associated domains are correctly configured under the "Signing & Capabilities" tab. Any typo or incorrect domain configuration can cause Universal Links to fail.
  4. iOS Console Logs: Use macOS’s Console app to view logs from your iOS device. This can provide insights into why a Universal Link might not be working as expected.

Common Pitfalls and How to Avoid Them

  1. Using HTTP Instead of HTTPS: Universal Links require HTTPS. Ensure all URLs in the AASA file are HTTPS.
  2. Mismatched App ID: The app ID in the AASA file must match your app’s actual app ID. Double-check for any typos or mismatches.
  3. Testing on Device: Always test Universal Links on a real device rather than the simulator, as some link-handling features may behave differently.

6. Best Practices for Universal Links

To maximize the effectiveness and reliability of Universal Links, consider the following best practices.

Ensuring a Seamless User Experience

  1. Fallback URLs: Always ensure that Universal Links have a web fallback. This way, if the app is not installed, users can still access the content in their browser.
  2. User Feedback: Provide visual feedback when a Universal Link is opened in the app. This helps users understand that the link has been correctly handled by the app.
  3. Deep Linking Context: Use deep linking to preserve the context of the user’s journey. For instance, if a user opens a specific article through a Universal Link, ensure that the app navigates directly to that article rather than just opening the home screen.

Handling Edge Cases

  1. Testing Across Versions: Test Universal Links across different versions of iOS to ensure compatibility and correct handling.
  2. Analytics and Monitoring: Implement analytics to track the usage of Universal Links. This can help identify patterns and potential issues.
  3. Regular Updates: Keep the AASA file and associated domains updated with any changes to your app’s URL structure or content paths.

Monitoring and Analytics

  1. Tracking Link Performance: Use tools like Google Analytics or custom tracking solutions to monitor how Universal Links are performing. This can provide insights into user behavior and any potential issues.
  2. Error Reporting: Implement error reporting to capture any failures in handling Universal Links. This data can be invaluable for debugging and improving the link-handling process.

By following these best practices, you can ensure that your Universal Links provide a reliable and smooth experience for your users.

7. Mobot's Role in Universal Links Testing

When it comes to ensuring the reliability and accuracy of Universal Links, leveraging specialized tools and services can be invaluable. Mobot provides automated testing services that can help streamline the testing process for Universal Links on iOS, ensuring that links perform as expected across various scenarios and devices.

How Mobot Can Assist in Testing Universal Links

  1. Automated Real Device Testing: Mobot utilizes a fleet of real devices to automate the testing of Universal Links. This ensures that links are tested in real-world conditions, across different iOS versions and device models, providing comprehensive coverage.
  2. Custom Test Scenarios: With Mobot, you can set up custom test scenarios tailored to your app's specific needs. For instance, you can automate tests for different link paths, user states (logged in vs. logged out), and app configurations.
  3. Consistent and Repeatable Tests: Automated tests provide consistency and repeatability. This means you can run the same set of tests after every deployment, ensuring that new changes do not break existing functionality.
  4. Detailed Reporting and Analytics: Mobot offers detailed reports and analytics on test outcomes. These insights can help identify patterns, potential issues, and areas for improvement.

Benefits of Using Mobot for Comprehensive Testing

  1. Time Savings: Automating Universal Links testing with Mobot can save significant time compared to manual testing. This allows your QA team to focus on other critical testing tasks.
  2. Increased Test Coverage: With the ability to test on a wide range of devices and configurations, Mobot ensures that your Universal Links work correctly for all users.
  3. Early Issue Detection: Automated testing can help detect issues early in the development cycle, reducing the cost and impact of fixing bugs later on.
  4. Scalability: As your app grows, maintaining a robust testing process becomes increasingly challenging. Mobot's scalable solutions can handle increased testing demands, ensuring that your app remains reliable and performant.

By integrating Mobot into your testing strategy, you can enhance the reliability of your Universal Links and ensure a seamless user experience.

8. Conclusion 

Ensuring the seamless functionality of Universal Links on iOS is essential for providing an integrated user experience that smoothly transitions between web and app content. By meticulously configuring the Apple App Site Association file, properly setting up associated domains in Xcode, and employing both manual and automated testing methods, you can effectively troubleshoot and resolve common issues. Adopting best practices, such as using fallback URLs and maintaining deep linking context, further enhances this process. Additionally, leveraging Mobot’s automated testing services can significantly streamline and scale your testing efforts, ensuring comprehensive coverage and reliability. Implementing these strategies will not only improve the usability of your app but also enhance user satisfaction and engagement.

How to Test Universal Links on iOS

Learn how to test Universal Links on iOS, including setup, troubleshooting, and best practices, ensuring a seamless user experience across web and app content.

Please Enter a Valid Business Email Address
Thank you! Please find the download link here:
Oops! Something went wrong while submitting the form.