Handling deep links to external apps in iOS using URL schemes is different from using Universal Links, particularly when integrating with services like Adjust or Branch. Universal Links provide a more seamless experience, allowing links to open in the app (if installed) or fall back to a webpage. These services use Universal Links to track and manage deep linking and provide analytics.
If you are not using universal links but still want to open another app from your app or push notifications, you need to manually handle that with URL schemes. That requires some additional code on your app.
Let’s say you are working on a partnership with another app. In your push notifications, you promote that app and want your users to go to the partner’s app.
For your app to open the partner app, you need to use the partner app's unique URL scheme in your deep link. When you create a deep link using this scheme, iOS checks if any installed app is registered to handle that particular scheme; suppose the partner app is installed and correctly set up with its URL scheme in its info.plist, iOS will open it.
1. Define URL Schemes
Defining a URL scheme involves specifying a unique identifier for each app, and it should not be the same across different apps. Each app must have its distinct URL scheme to ensure the iOS system correctly identifies which app to open when the URL is triggered. The app you want to link to also needs to have its URL scheme set up in its info.plist file. This ensures that when the unique URL scheme of the external app is called, the iOS system knows to open that specific app.
2. Handling Deep Links
In your app, when you want to open the external app, check if the app can be opened and then use UIApplication.shared.open:
3. Fallback Mechanism
If the external app is not installed, redirect users to a web page or the App Store. This improves the user experience and reduces friction.
Test the deep linking functionality across various devices and iOS versions to ensure compatibility and reliability.
If the partner app isn’t opening, check these points:
- Ensure the partner app’s URL scheme is correctly registered in its info.plist.
- Verify that your deep link correctly uses the partner app’s URL scheme.
- Make sure the partner app is installed on the testing device.