TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | Custom |
ReleasedLast Release | Nov 2016 |
Maintained by Ivan Bruel, Hugo, Ricardo.
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.
Hoko
folder to your project.SystemConfiguration.framework
and libz.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/.