We recently built functionality for users of our app, Trapeze, to send a date spot to others through a link. The recipient can tap on the sent link; if they have Trapeze installed, it opens and displays the sent date spot. Otherwise, they are redirected to download Trapeze from an app store.For iOS, universal links provide the behavior we want. A universal link looks like a link to a webpage on your website. With the proper setup, your app can detect when a user taps on a universal link and display content based on the URL. For users who don’t have your app, the universal link opens in a web browser like a regular link, which can then redirect to the iOS App Store.The setup process for universal links has three high-level steps:
Create an apple-app-site-association file that contains JSON data about the URLs that your app can handle.
Upload the apple-app-site-association file to your HTTPS web server. You can place the file at the root of your server or in the .well-known subdirectory.
Prepare your app to handle universal links.
If you created your website with Bitnami WordPress on Amazon Web Services like we did (see here for how to set that up), you may have questions when you get to step B. Where is the root directory of my server? Do I need to make any configuration changes? How do I know I’ve set everything up correctly?For anyone else trying to upload an association file for iOS universal links to a website built on Bitnami WordPress, I’ve described the steps below. If you’re not familiar with how to connect to your server via SFTP/SCP and SSH, see here and here respectively.
Create the apple-app-site-association file as specified in the setup process. You can find the required Team ID at your Apple Developer account Membership page.
Go to the /opt/bitnami/apps/wordpress/htdocs directory on your server. This is where the root of your website resides.
Upload the association file by either:
Directly copying the file into the htdocs directory, or
First creating a new subdirectory called .well-known in htdocs, then copying the association file into .well-known
Change the working directory to /opt/bitnami/apps/wordpress/conf. You will need to make a change in a configuration file here so that the association file has the correct content type header.
This directory should contain a file named httpd-app.conf. Within this file, you should see a <Directory “/opt/bitnami/apps/wordpress/htdocs”> … </Directory> tag pair.
If you copied the association file directly into htdocs in step 3, add the following within this tag pair: <Files apple-app-site-association>
Header set Content-type “application/pkcs7-mime”</Files>
If instead you copied the association file into .well-known in step 3, add the following after this tag pair: <Directory /opt/bitnami/apps/wordpress/htdocs/.well-known> <Files apple-app-site-association>
Header set Content-type “application/pkcs7-mime” </Files></Directory>
Run the command sudo apachectl -k graceful on the server through SSH. This command reloads Apache with the configuration change you made in the previous step.
Verify that your website is now properly set up with this tool. If so, all checks should pass.
That takes care of the association file. All that’s left is to update your app delegate to respond with the desired behavior in your app. When building, you will need to enable Associated Domains under Capabilities in Xcode. Then, enter the domains that your universal links should handle. Once this is done, your app’s implementation of universal links should be ready to use!