Hoko 2.5.0

Hoko 2.5.0

TestsTested
LangLanguage Obj-CObjective C
License Custom
ReleasedLast Release Nov 2016

Maintained by Ivan Bruel, Hugo, Ricardo.



Hoko 2.5.0

  • By
  • Hoko S.A., Hugo Sequeira, Ivan Bruel, Ricardo Otero and Pedro Vieira

Quick Start - HOKO framework for iOS

This document is a quick start introduction to the HOKO framework for iOS (only iOS 5 and higher). You can read the full documentation at http://hokolinks.com/documentation#ios.

To integrate HOKO in your app, simply follow the 3 simple steps below after adding it to your project.

Install HOKO in your project

Framework

  1. Download the Hoko SDK.
  2. Drag the Hoko folder to your project.
  3. Be sure to also add SystemConfiguration.framework and libz.dylib in case your project does not include it already.

Integrating the SDK with your Swift project

Because the HOKO SDK is written in Objective-C, you'll have to manually add a Bridging Header file into your project in order to use it with your Swift code:

  • File > New > File... > iOS > Source > Header File

  • Name that header file YourAppName-Bridging-Header.h

  • Inside that header file, import #import <Hoko/Hoko.h>

  • Go to your project > Build Settings > Objective-C Bridging Header > add the path to your bridging header file, from your root folder (e.g. MyApp/MyApp-Bridging-Header.h)

  • Get Swifty!

SDK Setup

Add the following line to your applicationDidFinishLaunching method in your AppDelegate class (don't forget to import the HOKO class by using #import <Hoko/Hoko.h> if you're working with Objective-C).

Objective-C

#import <Hoko/Hoko.h>

- (BOOL)application:(UIApplication *)application
        didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [Hoko setupWithToken:@"YOUR-APP-TOKEN"];
    // The rest of your code goes here...
}

Swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    Hoko.setupWithToken("YOUR-APP-TOKEN")
    // The rest of your code goes here...
}

1. Add a URL Scheme to your App

To register a URL scheme you should navigate to your project's application target, select the info tab, and under URL Types click the plus sign. Once there you should assign a custom (and unique) URL scheme. Following Apple's guidelines is should be in reverse DNS notation (e.g. com.hoko.hokotestbed).

URL Scheme

2. Deeplinking

To map routes to your View Controllers all you have to do is map them in the deeplinking module on your applicationDidFinishLaunching method in your AppDelegate class.

Objective-C

[[Hoko deeplinking] mapRoute:@"product/:product_id" toTarget:^(HOKDeeplink *deeplink) {
    BLKProductViewController *productViewController = [[BLKProductViewController alloc] initWithProductId:deeplink.routeParameters[@"product_id"]];
    productViewController.referrer = deeplink.queryParameters[@"referrer"];
    [HOKNavigation pushViewController:productViewController animated:YES];
}];

Swift

Hoko.deeplinking().mapRoute("product/:product_id", toTarget: { (deeplink: HKDeeplink!) -> Void in
    let productViewController = BLKPRoductViewController(productId: deeplink.routeParameters["product_id"])
    productViewController.referrer = deeplink.queryParameters["referrer"]
    HOKNavigation.pushViewController(productViewController, animated: true)
})

In order to perform certain tasks whenever a deep link enters the application, a Handler may be added to the Deeplinking module. This makes it easier to track deep links to analytics platforms, log entries or update your database.

Objective-C

[[Hoko deeplinking] addHandlerBlock:^(HOKDeeplink *deeplink) {
    [[Analytics sharedInstance] track:"deeplink" parameters:@{@"route": deeplink.route}];
}];

Swift

Hoko.deeplinking().addHandlerBlock { (deeplink: HOKDeeplink!) -> Void in
    Analytics.sharedInstance().track("deeplink", parameters: ["route": deeplink.route])
}

Full documentation

We recommend you to read the full documentation at http://support.hokolinks.com/quickstart/ios/.