Login

Integration Tools

iOS Integration Test

iOS Device Event Log

Android Integration Test

Android Device Event Log

Sandbox Event Log

iOS Device Event Log
NOTE Go to pre SDK 2.0.0 instructions

Switch to Swift instructions
Start Understanding
Your People
Enable
Personalized Push
Enrich Your
People Profiles
  • First, get the Kahuna SDK into your app. Choose one of the two options to get Kahuna SDK.
    Cocoa Pods
    Manual Download
    • 1.Install CocoaPods first if you have not set it up yet. show me
      Open up command prompt and type in the following.
      $ sudo gem install cocoapods
      2.Create the Pod file and add Kahuna's pod in it. Kahuna's pod is called 'Kahuna'. show me
      Open a command prompt and run the following command in the same directory as your .xcodeproj file. This will create a default pod file called 'Podfile'.
      $ pod init
      Open the 'Podfile' and add the following line between the 'target' and 'end' lines of your project. Save the file.
      Note : There is an old CocoaPod 'KahunaSDK'. Please do not use that pod as it is only available for existing customers who still use that Pod.
      pod 'Kahuna', '2.3.1'
      3.Install the Kahuna Pod by running 'pod install' on the command line. show me
      On the command line go to the directory where you have the 'Podfile' file and run the following command.
      $ pod install
      Once the pod is installed you will see something like this on your command line.
      Installing the Pod creates a new workspace, that includes your project as well as a CocoaPods project. Use the workspace to open your project going forwards. This enables building the cocoa pods each time you build your app.
      To update the pod regularly run the 'pod update' command. show me
      Open up command prompt, go to your project directory and type the following
      $ pod update
    • 2. Add SystemConfiguration.framework, CoreLocation.framework to your project. show me
      To use the Kahuna SDK, you need to have SystemConfiguration.framework in your project. In Xcode, navigate to and expand the "Frameworks" folder.
      Right click on "UIKit.framework" and select "Show in Finder".
      This will bring up your Finder. In this window find the SystemConfiguration.framework folder and drag it into the Frameworks folder in your Xcode project.
      Doing this will bring up a window resembling this one.
      For Destination, make sure nothing is selected.
      For Folders, make sure Create groups for any added folders is selected.
      For Add to targets, make sure your project is selected.
      Click Finish
      3. Add the Kahuna lib to your project and set your -ObjC linker flag. show me
      Note Please make sure your project contains the linker flags "-ObjC" otherwise all objects in the Kahuna static library will not get linked at runtime.
      Unzip the file and drag the "Kahuna" folder into the Xcode project you wish to integrate Kahuna with.
      Doing this should bring up a dialog resembling this one.
      For Destination, make sure Copy items into destination group's folder is selected.
      For Folders, make sure Create groups for any added folders is selected.
      For Add to targets, make sure your project is selected.
      Click Finish
      Now that you've got all the files you need in place, it's time to start using the Kahuna SDK.
    Now, what data do you have on the people who use your app?
    May have Username/Email
    May have Other Credentials
    Anonymous Only
    • Your app allows some form of user login and/or registration. Some users can continue to use your app anonymously if they want.
      4. In your application delegate, incorporate the following lines:
      IMPORTANT! Please make sure usernames & emails are UNIQUE across all your users. Why?
      #import "Kahuna.h"
      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
      {
          [Kahuna launchWithKey:@"INSERT_APP_KEY"];
          KahunaUserCredentials *uc = [Kahuna createUserCredentials];
          [uc addCredential:KAHUNA_CREDENTIAL_USERNAME withValue:@"User's name"];
          [uc addCredential:KAHUNA_CREDENTIAL_EMAIL withValue:@"User's email"];
          NSError *error = nil;
          [Kahuna loginWithCredentials:uc error:&error];
          if (error) {
             NSLog(@"Login Error : %@", error.description);
          }
      
          // Add your app initialization code here
          return YES;
      }
      
    • Your app allows some form of user login and/or registration. Some users can continue to use your app anonymously if they want. This page is to allow your app to pass in even more credentials besides just username and email.
      4. In your application delegate, incorporate the following lines:
      IMPORTANT! Please make sure all user credentials are UNIQUE across all your users. Why?
      #import "Kahuna.h"
      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
      {
          [Kahuna launchWithKey:@"INSERT_APP_KEY"];
          KahunaUserCredentials *uc = [Kahuna createUserCredentials];
      [uc addCredential:KAHUNA_CREDENTIAL_USER_ID withValue:@"User's Id"];
      [uc addCredential:KAHUNA_CREDENTIAL_USERNAME withValue:@"User's name"];
      [uc addCredential:KAHUNA_CREDENTIAL_EMAIL withValue:@"User's email"];
      [uc addCredential:KAHUNA_CREDENTIAL_FACEBOOK withValue:@"User's facebook id"];
      [uc addCredential:KAHUNA_CREDENTIAL_TWITTER withValue:@"User's twitter id"];
      [uc addCredential:KAHUNA_CREDENTIAL_LINKEDIN withValue:@"User's linkedin id"];
      [uc addCredential:KAHUNA_CREDENTIAL_GOOGLE_PLUS withValue:@"User's google plus id"];
      [uc addCredential:KAHUNA_CREDENTIAL_INSTALL_TOKEN withValue:@"User's install token"];
      NSError *error = nil; [Kahuna loginWithCredentials:uc error:&error]; if (error) { NSLog(@"Login Error : %@", error.description); } // Add your app initialization code here return YES; }
    • Your app does not allow user login or user registration in any form.
      4. In your application delegate, incorporate the following line:
      #import "Kahuna.h"
      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
      {
          [Kahuna launchWithKey:@"INSERT_APP_KEY"];
      
          // Add your app initialization code here
          return YES;
      }
      
  • The Kahuna iOS SDK now supports sending targeted push notifications! Follow these steps to get it hooked up in your app after you have done the basic integration.
    1. Generate your CSR - show me
    You'll need to generate a Certificate Signing Request (CSR) in order to create a Push SSL Certificate for your app. (if you already have a CSR for your app, you may skip this step). You can do this by opening Keychain Access on your Mac (in Applications/Utilities) and choosing Keychain Access => Certificate Assistant => Request a Certificate from a Certificate Authority...
    You should see a Certificate Assistant window pop-up. From there you must fill out the User Email Address and Common Name fields to be your email and the Common Name for your application (ex: My App Dev). Finally, check the Saved to disk option and click Continue to save your CSR.
    2. Generate Push SSL Certificate - show me
    After that, you'll need to configure your app to enable Push Notifications (if your app already supports Push, you may skip this step). This step will generate a Push SSL Certificate that you can upload to Kahuna in order to allow us to push notifications on your behalf.
    First you'll need to ensure your application is properly provisioned in the iOS Provisioning Portal.
    Note Your application must have a valid Bundle Identifier (including Development builds) as Push does not support the wildcard App ID.
    In the App IDs area of the iOS Provisioning Portal you should see a description for your application as well as little green or gray indicators for Push Notification for both Development and Distribution. Click Edit to continue, and you will need to be the Team Agent to configure your app.
    You should then see a screen to allow you to Enable Apple Push Notification service for Development and Production. (You will need to enable for both if you plan to test first against development which is Highly Recommended). Click on the Create Certificate.. button and point to the CSR you created from Step 2 above to generate your Push SSL Certificate.
    Once you click Create Certificate, just follow the steps to specify your CSR from Step 1 to finish generating your Push Certificate.
    3. Upload Push Certificate to Kahuna - show me
    Once you have created a Push SSL Certificate, you will need to upload it to Kahuna. After you have generated your Push SSL Certificate, you will get directed back to the Enable Push Notification page where you should see the status indicator showing green and Enabled. Click Download to download your Push SSL Certificate.
    After you download your certificate, opening it will open Keychain Access. Your certificate should be shown under My Certificates. Select the certificate that was just added and select File -> Export Items... from the menu.
    When saving the file, user the Personal Information Exchange (.p12) format, and pick the name carefully as you will upload this file to Kahuna.
    To upload your .p12 or .pem certificate files, please visit the settings page and scroll to the 'Push Authorization' section.
    4. Integrate SDK Calls for Push - To support Push in your application, incorporate the following lines into your application delegate: (Note: Push must be tested on an actual device, it will not work in the simulator)
    Do one of the following 2 options.
    Deep Integration (Preferred)
    Regular Integration
    • Option I : (Preferred mechanism). Call Kahuna method setDeepIntegrationMode.
      If you are using Deep Integration make sure you do not have any Kahuna specific code inside didRegisterForRemoteNotificationsWithDeviceToken, didFailToRegisterForRemoteNotificationsWithError & didReceiveRemoteNotification.

      Deep Integration makes some of the integration steps for you automatically, so it is less work for you. Having code for both mechanisms can cause un-expected results!!
      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
      {
          [Kahuna setDeepIntegrationMode:true];
      
          // Call other Kahuna integration APIs here. Eg : launchWithKey, loginWithCredentials etc.
      
          if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerForRemoteNotifications)]) {
              UIUserNotificationType types = UIUserNotificationTypeAlert | UIUserNotificationTypeSound |
                                           UIUserNotificationTypeBadge;
              UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types
                                                                                     categories:nil];
              [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
              [[UIApplication sharedApplication] registerForRemoteNotifications];
          } else {
              UIRemoteNotificationType types = UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound |
                                             UIRemoteNotificationTypeBadge;
              [[UIApplication sharedApplication] registerForRemoteNotificationTypes:types];
          }
      
         NOTE
          // If you are implementing didReceiveRemoteNotification:fetchCompletionHandler then do not call [Kahuna handleNotification] here.
          // Otherwise please call handleNotification as shown below.
          [Kahuna handleNotification:[launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]
                                          withApplicationState:application.applicationState];
      
          // Add your app initialization code here
          return YES;
      }
      
      - (void) application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
      {
          [[UIApplication sharedApplication] registerForRemoteNotifications];
      }
      
    • Option II : Add in the following methods to your application delegate.
      Please make sure you do NOT have Deep Integration turned on. (Calling setDeepIntegrationMode with true, turns on Deep Integration). Having code for both mechanisms can cause un-expected results!!
      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
      {
          // Call other Kahuna integration APIs here. Eg : launchWithKey, loginWithCredentials etc.
      
          if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerForRemoteNotifications)]) {
              UIUserNotificationType types = UIUserNotificationTypeAlert | UIUserNotificationTypeSound |
                                           UIUserNotificationTypeBadge;
              UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types
                                                                                     categories:nil];
              [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
              [[UIApplication sharedApplication] registerForRemoteNotifications];
          } else {
              UIRemoteNotificationType types = UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound |
                                             UIRemoteNotificationTypeBadge;
              [[UIApplication sharedApplication] registerForRemoteNotificationTypes:types];
          }
      
          NOTE
          // If you are implementing didReceiveRemoteNotification:fetchCompletionHandler then call [Kahuna handleNotification] in that method.
          // Otherwise please call handleNotification as shown below.
          [Kahuna handleNotification:[launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]
                                          withApplicationState:application.applicationState];
      
          // Add your app initialization code here
          return YES;
      }
      
      - (void) application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
      {
          [[UIApplication sharedApplication] registerForRemoteNotifications];
      }
      
      - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
      {
          [Kahuna setDeviceToken:deviceToken];
      }
      
      - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
      {
          [Kahuna handleNotificationRegistrationFailure:error];
      }
      
      
      Regular Push Notifications
      - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { [Kahuna handleNotification:userInfo withApplicationState:application.applicationState]; }
      Actionable Push Notifications
      - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)actionIdentifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler { [Kahuna handleNotification:userInfo withActionIdentifier:actionIdentifier withApplicationState:application.applicationState]; // Call the completion handler here }
    Optional Push Features
    1. Receive Callback when Receiving a Kahuna Push Notification - Just in case you were wondering, the Kahuna SDK can notify you if your application receives a Push notification sent from Kahuna. You just need to implement the Protocol in your Application Delegate file as shown below:
    #import "Kahuna.h"
    @interface AppDelegate : UIResponder <UIApplicationDelegate, KahunaDelegate>
    
    And then, in your Application Delegate .m file, you can implement the Kahuna Push protocol and assign the delegate to your own class to be called. Note: If you import Kahuna.h in your header file you can remove the import of Kahuna from your implementation file.
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Set AppDelegate as the delegate for Kahuna Push Notifications
        [Kahuna sharedInstance].delegate = self;
    
        // Call other Kahuna integration APIs here. Eg : launchWithKey, loginWithCredentials etc.
    
        // Add your app initialization code here
        return YES;
    }
    

    With Kahuna you can even pass in some extra parameters to your own application and receive them from the Notification Delegate as shown below. Note: You should decide what custom params (if any) your app will support and add any error handling logic in case a push you receive does not contain any extra parameters.

    - (void)kahunaPushMessageReceived:(NSString *)message withDictionary:(NSDictionary *)extras
                                                    withApplicationState:(UIApplicationState)applicationState
    {
        NSLog(@"Received Push from Kahuna!");
        // Check on the applicationState before deep-linking into the app
        // Push received when app is in Foreground should not take users to specific view via DeepLinking.
        // Non view navigation code can still be performed when Push is received with app in foreground.
        NSString *value = [extras valueForKey:@"DEEP_LINKING_PARAM_KEY"];
        if (value) {
            if (applicationState != UIApplicationStateActive) {
                // Deep link into the app.
            } else {
                // Push came when the app is in Foreground. You can show an UIAlertView dialog with the message.
                // When the user clicks on the "OK" button, Deep link into the app.
            }
        }
        // For iOS8 actionable push notifications we will send the selected action in this callback.
        // Actionable push notifications does not need the applicationState check as the user cannot
        // take an action when the app in foreground.
        if ([extras valueForKey:@"k_action_identifier"] != nil) {
            NSString *pushAction = [extras valueForKey:@"k_action_identifier"];
            // Act on the pushAction to perform actions for the user.
        }
    }
    
    2. Badging - The Kahuna SDK provides methods for setting and getting your application's badge number. Below are examples of how you can utilize these methods in your app:

    Note: You should set and get the badge number wherever you think is appropriate; the examples below simply illustrate how to perform the correct method calls.

    Set the badge number:

    [Kahuna sharedInstance].badgeNumber = 2;
    

    Get the badge number:

    NSInteger badgeValue = [Kahuna sharedInstance].badgeNumber;
    
    Once these steps are completed, your team will have a robust push notification delivery system capable of targeting key groups of users.
  • Want to run campaigns based on what your users do and who they are? Set up Custom Events and Custom Attributes to make this happen!
    1. Put in some custom events with the following line:
    [Kahuna trackEvent:@"EVENT_NAME_HERE"];
    Then, go head and launch your app and trigger some of your custom events. We'll wait.
    Waiting for an event...
    2. Kahuna allows you to further characterize your users by specifying additional user attributes:
    NSDictionary *userAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
              @"John", @"first_name", // User's first name
              @"Q", @"last_name", // User's last name
              @"m", @"gender", // User's gender
              [NSNumber numberWithInt:1], @"birth_day", // User's birth day
              [NSNumber numberWithInt:1], @"birth_month", // User's birth month
              [NSNumber numberWithInt:1989], @"birth_year", // User's birth year
              nil];
    
    [Kahuna setUserAttributes:userAttributes];
    
    Optional Features
    1. Associate a count and value to your Event - Kahuna allows you to specify additional count and value information to an Event you track, the most obvious of which is to track user purchases. For instance, if you wanted to track a user purchase of 2 items for $5.00 total, you would pass 2 for count and 500 for value. :
    [Kahuna trackEvent:@"EVENT_NAME_HERE" withCount:2 andValue:500];
    Setting count and value to an Event is optional, but allows deeper tracking of your user behavior. For example if you wanted to track purchase information and LTV per user.