The HOKO framework is an easy to use deep linking framework that enables an app to map deep linking routes to actual behavior in the app. This behavior can include showing a particular screen or performing a certain action. HOKO also allows users to be redirected to your app regardless of the platform they are on.
After integrating HOKO, you will be able to open your app by using URI links such as...
your.app.scheme://<mapped_route>/<route_param>?<query_params>
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 CocoaPods in your system
-
Open your Xcode project folder and create a file called
Podfile
with the following content:pod 'Hoko', '~> 2.2'
-
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
.
- Download the Hoko SDK.
- Drag the
Hoko
folder to your project. - Be sure to also add
SystemConfiguration.framework
andlibz.dylib
in case your project does not include it already.
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!
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...
}
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).
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])
}
We recommend you to read the full documentation at http://support.hokolinks.com/quickstart/ios/.