Latest 2.5.0
Homepage https://github.com/hokolinks/hoko-ios
License Apache
Platforms ios 5.0, requires ARC
Frameworks Foundation, SystemConfiguration, UIKit
Authors , , , ,

Hoko

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

CocoaPods

  1. Install CocoaPods in your system
  2. Open your Xcode project folder and create a file called Podfile with the following content:

    pod 'Hoko', '~> 2.5'
  3. Run pod install and wait for CocoaPod to install HOKO SDK. From this moment on, instead of using .xcodeproj file, you should start using .xcworkspace.

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/.

Latest podspec

{
    "name": "Hoko",
    "version": "2.5.0",
    "platforms": {
        "ios": "5.0"
    },
    "license": "Apache",
    "summary": "Connect all your platforms with a single link with HOKO deep linking technology",
    "homepage": "https://github.com/hokolinks/hoko-ios",
    "social_media_url": "https://twitter.com/hokolinks",
    "authors": {
        "Hoko S.A.": "[email protected]",
        "Hugo Sequeira": "[email protected]",
        "Ivan Bruel": "[email protected]",
        "Ricardo Otero": "[email protected]",
        "Pedro Vieira": "[email protected]"
    },
    "source": {
        "git": "https://github.com/hokolinks/hoko-ios.git",
        "tag": "v2.5.0"
    },
    "requires_arc": true,
    "public_header_files": "Hoko/*.h",
    "source_files": "Hoko/*.{h,m}",
    "frameworks": [
        "Foundation",
        "SystemConfiguration",
        "UIKit"
    ],
    "libraries": "z"
}

Pin It on Pinterest

Share This