deeplinking-img-v2

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

Screen Shot 2015-08-14 at 2.57.22 pm

 

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;
}

 

Deep Linking

Aadil Keshwani

People call me geek i call myself Coder. I like to explore & learn new things, R&D and Innovation motivates me. By profession i am iPhone Developer but i have sound knowledge of PhoneGap, HTML, CSS3, WordPress, Photoshop, PHP, CodeIgniter, OpenCart. Feel free to contact me for any queries or help in above technologies, i would be more than happy to help you out.

Category: Uncategorized
1
4575 views

1 comment

  • Great Work…
    Really Interesting Stuff…opening an app through URL…!!!
    Thanks…Aadil…!!!

Comments are closed.