Deep linking in iOS allows you to direct users to specific content within an app, making your app more accessible and enhancing the user experience. In this guide, we’ll walk you through the steps to set up deep linking using the Info.plist
file and bundleURLSchemes
to extract the correct URL schemes and create meaningful deep links to enhance the user journey.
Step-by-Step Guide
One crucial part of setting up deep linking is finding the correct URL scheme for your app. This information is stored in the Info.plist
file of your app.
1. Locate the Info.plist
File
The Info.plist
file is a configuration file that contains key-value pairs related to the app’s settings.
- Find the file named
Info.plist
associated to the app. - If opening the project, it’s usually located in the
Supporting Files
group or directly in the project root. - If you are wanting to reference an already downloaded app's
Info.plist
file, usually found by searching in the search bar or right-clicking each item to "Show Package Contents" until theInfo.plist
file is located.
2. Open the Info.plist
File
You can open the Info.plist
file using a text editor or a dedicated plist editor. Some examples of text editors include Notepad++, Xcode, Visual Studio Code.
3. Find the CFBundleURLTypes
Key
The CFBundleURLTypes
key contains an array of dictionaries, each representing a URL scheme that the app supports. This key is used to define custom URL schemes that the app can handle.
- In the
Info.plist
editor, look for theCFBundleURLTypes
key. Expand it to see the array of URL schemes. - In in XML format, search for the
CFBundleURLTypes
key. It will look something like this:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
<string>myapp2</string>
</array>
</dict>
</array>
4. Identify the URL Schemes
Within the CFBundleURLTypes
key, look for the CFBundleURLSchemes
key, which lists the URL schemes. Each scheme is a string that represents a custom URL scheme your app can handle.
In the example XML snippet above:
- The app supports the URL schemes
myapp
andmyapp2
.
5. Formulate the Deep Link
A deep link to your app is created using these URL schemes. You can format a deep link like this:
myapp://some/path
or
myapp2://another/path
The URL scheme (myapp
or myapp2
) is followed by a path, which could be specific to what you want to link to within the app.
Testing the Deep Link
To test the deep link, you can:
- Use a web browser: Enter the URL scheme in Safari’s address bar (e.g.,
myapp://some/path
or simplymyapp://
), and it should open the app if it’s installed and correctly handles the scheme. - Use the
window.open
Method: You can programmatically test the deep link using thewindow.open
method.
const appDeepLink = 'app://';
window.open(appDeepLink, '_blank');
Finding and utilizing deep links in iOS apps involves identifying the correct URL schemes from the Info.plist
file.
Conclusion
Mobile app deep linking can be tricky—there is no one-size-fits-all solution. Following the steps outlined above, you can efficiently locate the CFBundleURLTypes
key in your app’s configuration, extract the URL schemes, and create meaningful deep links to enhance app navigation and user engagement.
Still have questions? Tevpro is here to help! Reach us via Twitter, Linkedin, or send us a message.
We'd love to hear from you. Happy deep linking!