iOS Deep Linking in iOS Setting up deeplink for your app

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Setting up deep-linking for your app is easy.You just need a small url using which you want to open your app.

Follow the steps to set up deep-linking for your app.

  1. Lets create a project and name it DeepLinkPOC.

  2. Now select your project target.

  3. After selecting target,select the 'info' tab.

  4. Scroll down to the bottom until you see an option of URL Types

  5. Click '+' option.

  6. You will see URL schemes add a string using which you want to open your app.Lets add "DeepLinking" in URL schemes.

So, to open your app you can launch it by typing "DeepLinking://" into your safari. Your deep-linking string has following format.

[scheme]://[host]/[path]  --> DeepLinking://path/Page1

where, Scheme : "DeepLinking" Host : "path" path : "Page1"

Note : Even if don't add host and path it will launch the app,so no worries.But you can add host and path to additionally redirect to particular page after application launch.

  1. Now add following method to your appdelegate.

Swift:

 func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool 

Objective-c:

-(BOOL)application:(UIApplication *)application
          openURL:(NSURL *)url
          sourceApplication:(NSString *)sourceApplication
          annotation:(id)annotation

The above method is called whenever your app is launched using a deep-linking string you set for your app.

  1. Now is the time to install your app but wait before you directly jump to run button.Lets do a small change in scheme's app-launch method.
  • Select and edit your scheme as

enter image description here

  • change its launch type and close enter image description here
  1. Now click the Run button (if you want you can add breakpoint to your didFinishLaunchingWithOptions and openURL methods to observe values)

  2. You'll see a message "Waiting for DeepLinkPOC(or your app name) to launch".

  3. Open safari and type in "DeepLinking://" into the search bar this will show prompt "open this page in DeepLinkPOC" click open to launch your app.

Hope you got to know how to set up deep-linking for your app :)



Got any iOS Question?