Integrate iOS SDK

To integrate HOKO open source SDK in your app you just have to follow 3 simple steps (either using cocoapods or doing it manually).

Using 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.0.2'

3. Run pod install and wait for CocoaPods to install HOKO SDK. From this moment on, instead of using .xcodeproj file, you should start using .xcworkspace.

Manual integration

1. Download the Hoko SDK.

2. Drag the Hoko folder to your project.

3. Be sure to also add SystemConfiguration.framework and zlib.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:

1. File > New > File... > iOS > Source > Header File

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

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

4. 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)

Add a URL Scheme to your App

Next, we need to define our custom URL type. Remember, we want to open the app via “hoko://”, so that will be our URL scheme. We also need to assign an unique identifier to the scheme. Apple recommends that you use reverse DNS notation to ensure that there are no name collisions on the platform, so we’ll use “com.hoko.app” for this example.

URL Scheme

Setup Associated Domains (Universal Links) - iOS 9.0+

For your app to fully support the newly introduced Universal Links by Apple you’ll have to enable and add a new entry in the Associated Domains section, inside your application target’s Capabilities tab. Click on the ‘+’ button and add a new entry with the following value: applinks:myapp.hoko.link, being myapp the Hoko subdomain you chose for your app’s Hoko links. You can also have your own link domain (learn more about this on the subdomains section).

URL Scheme

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

#import <Hoko/Hoko.h>
- (BOOL)application:(UIApplication *)application
  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [Hoko setupWithToken:@"YOUR-APP-TOKEN"];
  // The rest of your code goes here...
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
  Hoko.setupWithToken("YOUR-APP-TOKEN")
  // The rest of your code goes here...
}

Setup iOS app →