DEEP LINKING
BhuShan PaWaR
Innovative Solution Architect specializing in Flutter, React Native, and iOS, driving the creation of exceptional cross-platform applications
Deep Linking at first seems to be very heavy & new concept but its actually very useful. But lets first understand what actually deep linking is all about. Assume that you have booked the ticket from app, and you have received an email of that ticket, Email can contain deep link to your app as well as link to website. Now if you open that email from mobile you will get deep link to your app. Clicking on that link you will be redirected to ticket screen in your app.
This particular link which opens app and redirect us to ticket detail screen can be termed as “Deep Linking”. Sounds good but how do we implement this in iOS ? And how can a URL open our app ?
Yes URL can open the app, if you dont believe me try opening Safari in your mobile and type whatsapp:// this will open whats app application. Formate of deep link is <Host>://<Path>/<Query>. Follow below step in order to achieve deep linking in your app.
Step 1 : Add URL Scheme in your info.plist
In URL Types -> item 0 -> URL Schemes -> item 0 -> ” <Replace with your custom scheme>”
To ensure this scheme is working try building the project and open safari & type <Custom Scheme>:// your application should open.
Step 2 :
We need to write the function to implement the same in our App Delegate in order to navigate User to perticular screen depending on the parameter & query supplied in the Deep Link URL
- -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
- {
- NSString *path = [url path];
- NSString *query = [url query];
- if ([query isEqualToString:@"1"])
- {
- vc = [story instantiateViewControllerWithIdentifier:@"homepage"];
- vc1 = [story instantiateViewControllerWithIdentifier:@"firstStoryboard"];
- self.navController=[[UINavigationController alloc] initWithRootViewController:vc];
- [self.navController pushViewController:vc1 animated:NO];
- self.window.rootViewController = self.navController;
- }
- return YES;
- }