How To Implement Deep Linking on iOS

Continued from page 1.

Using Button DeepLink SDK

Button’s DeepLink SDK is part of the company's suite of solutions including its Loyalty/Rewards Program API, DeepLink Commerce and CartAdjust, which applies DeepLink and commerce promotions and link them to the app’s cart.

Similar to the other deep-linking solutions we evaluated, Button DeepLink SDK provides a route-handling mechanism that allows for passing and handling of data, then routes (or navigates) to the specific contextual content. However, unlike App Links, DeepLink is iOS-only.

Getting started with Button DeepLink SDK

image

Getting started with this SDK is extremely straightforward, using the popular CocoaPods package-management framework:

pod "DeepLinkSDK"

We will start with The Router, which will be centralized in your application’s AppDelegate file:

- (BOOL)application:(UIApplication *)application
        didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  self.routerManager = [[**DPLDeepLinkRouter** alloc] init];

  return YES;
}

We need to register Routes, which can be done in the following fashion:

...
self.routerManager[@"/profile/:username"] = ^(DPLDeepLink *link){

ProfileViewController* pvc = [[ProfileViewController alloc] initWithProfileUserName:link.routeParameters[@"username"]
// we then would call the view controller passing after initialising with the link parameters
...

Receiving Deep Links and assigning them to the router is done in a similar way to how we did it with App Links, using the application:openURL:sourceApplication:annotation: method override in AppDelegate. The following handles the url passed in, and assigns it to the routerManager object we declared earlier:

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

  [self.routerManager handleURL:url withCompletion:NULL];

  return YES;
}

Routes can also be assigned to classes instead of blocks, as follows:

self.routerManager[@"/profile/:profile_id"] = [ProfileRouteHandler class];

If the view controller receives a URL with the path of /profile/1234, the router will then instantiate through the handler subclassing your target view controller, passing in the appropriate information. We will need to conform to the DPLTargetViewControllerProtocol so that we can implement the configureWithDeepLink: method:

- (void)configureWithDeepLink:(DPLDeepLink *)deepLink {

    NSString *profileId = deepLink.routeParameters[@"profile_id"];
    self.profile = [Profile profileWithId: profileId];
}

DeepLink and App Links are very similar in a way, from the elementary route-mapping to supporiting link-handling from external origins, such as web Wages or native apps. This SDK, however, is a substantial subset of App Links, as it does not support navigating backward and is not cross-platform (so you are stuck with iOS).

You also don’t get the smarter logic that allows for things like failing links (such as when the user does not have the app). Not being open-sourced, you also don’t get the large and engaged community that App Links enjoys.

What you do get, however, is an easy to use SDK--much easier to use, certainly, than AppLinks.

 

Comments (12)

Julie Elangwey

 How to set up Apple Universal Links on iOS 9 to deep link on iPhone app.

walterdf

how do I pass multiple parameters?

programmableweb://news/{paramName1}_{paramValue1}/{paramName2}_{paramValue2}/...

Thanks,

Walter

doronkatz

For that Walter, using components(separatedByString:xxx) and store as an array, access the individual properties, would be a good approach to take

Paulcarder

Java is an amazing language, and the more I learn through the Java forum, the more I get impressed with the way people make use of it for creating websites, mobile games, and apps.

cjsm_menezes

Don,

Nice to meet you.

Do you have this code for Swift ? I have a problem. When my app receives the deep link by Face (https://fb.me/680438488793610) the app falls. Should I made some mystake ?  When I call the app via Safari using the url scheme biblianvt://?a=2&b=3:3 (for example) the app works perfectly.

Thanks for your help

Claudio - cjsm_menezes@yahoo.com.br

cjsm_menezes

claudio

Doron, good morning.

Does that code bring the querystring of the app link URL ? My app publishes a Facebook app link like that: 

https://fb.me/682225125281613?a=7&b=3:7

When user taps in this posts my app should read this querystring after the "?"

Could you send your code in Swift ? I need read the querystring to deal and go to a específic view controller.

 

Thanks

Claudio 

cjsm_menezes@yahoo.com.br

 

 

doronkatz

In addition to my previous post, answering your question Claudio, BF should ideally expose properties similar to:

{ "target_url": "https://www.example.com/abc.html", "extras": { "fb_app_id": [YOUR_FACEBOOK_APP_ID], "fb_access_token": "[ACCESS_TOKEN']", "fb_expires_in": "3600" }, "referer_app_link": { "url": "[FACEBOOK_APP_BACK_LINK]", "app_name": "Facebook" } }

Link

However, in the link I sent you on RayWenderlich, you create an  apple-app-site-association and then implementing:

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {

...

Apps-Kpt

Really appreciate for your amazing article. Keep going on, good stuff. Thank you for this valuable information.   appvn

Click-Hunk

Thanks for sharing this great. Keep sharing more useful and conspicuous stuff like this. Thank you so much.

fastpokemap

bean-Chao

Keep sharing more useful and conspicuous stuff like this. Thank you so much 

 

bean-Chao

Very Helpful Information… 

Thanks for sharing.