The answer to this problem is to use Associated Domains (but after 9.2 we should use Universal Links to achieve this).
Before Universal Links, the main mechanism for opening an application when it was installed was an attempt to redirect to the application URI scheme (registered in PLIST applications like this) in Safari. This put the routing logic in Safari, but there was no way to check if the application was installed or not.
iOS 9 Universal Links were designed to fix this. Instead of opening Safari first when you click the link, iOS checks to see if a universal link has been registered for the domain associated with the link, and then check if the corresponding application is installed. If the application is installed, it will open. If not, Safari will open and the http (s) link will be downloaded.
Functionally, this allows you to have one link that will either open your application or open your mobile site.
Configure the application to register approved domains
- Register your application at developers.apple.com
- Include 'Linked Domains in your App ID
- Enable Linked Domain in Xcode Project
- Add the correct domain right
- Make sure the permissions file is included in build
Set up your website to host the apple-app-site-association file
- Buy a domain name or choose from an existing one
- Get SSL certificate for domain name
- Create a structured JSON file for the Apple-app-site-association.
- Sign JSON file with SSL certificate
- Configure file server
Apple launched Universal Links on iOS 9.0, which moves application routing to the OS so that developers don’t have to worry about doing routing in Javascript.
Getting the universal URL in the application
URI schemes got the deep link URL through openUrl in the application’s deletion. Generic links get their data using another code: continueUserActivity . This new delegate method is used for several application transitions, from Spotlight to Universal Links, and is likely to see a couple more use cases introduced in future versions of the OS.
Below is a snippet of code that you can use to get the full URL of the universal link that the application opened.
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler { if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) { NSString *myUrl = [userActivity.webpageURL absoluteString];
Source: https://blog.branch.io/how-to-setup-universal-links-to-deep-link-on-apple-ios-9
source share