Objective-C
This guide describes how to use the Kaa Objective-C SDK within your application.
Requirements
Make sure that the following components are installed on your machine:
- Xcode 7.x or later.
- CocoaPods 1.x.x or later.
Installation
To install a Kaa SDK in your project as a third-party framework, use the CocoaPods dependency manager.
To generate your Objective-C SDK:
-
Click the Source button. A project source download window will open. Click Ok and download the
.tar.gzfile. -
Unpack the downloaded archive into your project directory and run the following command from that directory.
pod initThis will create a file named
PodfileYou can also create it manually using a text editor.If you create the
Podfilefile using thepod initcommand, add the following line to include your Kaa SDK as a pod.pod 'Kaa', :path => './libs/kaa-ep-sdk'If you create the
Podfilefile using a text editor, make sure to include the following content.use_frameworks! target '<PROJECT_NAME>' do pod 'Kaa', :path => './libs/kaa-ep-sdk' endIn the example above, PROJECT_NAME is the name of your project target.
TIP: If you want to deploy your Kaa instance in a Swift project, add the
use_frameworks!command as the first line in yourPodfilefile. This step is required if you don’t want to import the bridging headers into your project. -
Run the following commands.
pod update pod installA log message will be created upon successful installation.
-
Open the
.xworkspacefile in Xcode. Your Kaa SDK is listed in the Development Pods group of the project tree.
Using endpoint SDK
To build your project using the Kaa Objective-C SDK:
-
Open the auto-generated
ViewController.hfile and create a property namedkaaClient.@property (nonatomic, strong) id<KaaClient> kaaClient;You can skip the declaration of a
kaaClientvariable and make it accessible to the controller only, but it should be visible and available outside theViewControllerimplementation. -
After the declaration, you will receive the ‘undeclared type’ error. To avoid this, make a forward declaration of the
KaaClientprotocol.@protocol KaaClient; -
Open the
ViewController.mfile and add the#import <Kaa/Kaa.h>header before the controller implementation. Make sure that your controller conforms to theKaaClientStateDelegateandProfileContainerprotocols, and that all required methods are implemented.
After this, Kaa SDK provides you with the Kaa class factory used to create a new instance of the Kaa client.
self.kaaClient = [KaaClientFactory clientWithContext:[[DefaultKaaPlatformContext alloc] init] stateDelegate:self];
Kaa Objective-C SDK is now successfully embedded into your project.
You can find auto-generated docs for Kaa Objective C SDK here.
Logging
Kaa Objective-C endpoint SDK uses CocoaLumberjack framework for logging. By default, the SDK logs warnings and errors only.
To change current SDK logging level, open the Kaa/KaaLogging.m file and assign one of the following constants to the ddLogLevel variable:
DDLogLevelVerboseDDLogLevelDebugDDLogLevelInfoDDLogLevelWarningDDLogLevelErrorDDLogLevelAllDDLogLevelOff