Set Up In-App Messaging

Set Up In-App Messaging

The Kahuna SDK for iOS provides support to allow you to send in-app messages to your users.

Note: SDK 2.4.0 and above provides Marketer-Driven In-App Messaging so that you can develop messages with unique content using one of several template styles provided by Kahuna. If you use Marketer-Driven In-App Messaging, no setup is required and you can skip this section; however, you must contact Customer Success to turn on this feature for your namespace. If your app already has an in-app message style that you want to keep, you can use Custom In-App Messaging, which requires the following setup.

To set up Custom In-App Messaging

  1. Add the KahunaDelegate as a protocol in your AppDelegate.

    Note: If you have already added the KahunaDelegate, skip this step.

    #import <Kahuna/Kahuna.h>
    @interface AppDelegate : UIResponder <UIApplicationDelegate, KahunaDelegate>
  2. In your AppDelegate, assign the delegate to your own class to be called when an in-app message arrives.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Set AppDelegate as the delegate for custom in-app Notifications
        [Kahuna sharedInstance].delegate = self;
        // Call other Kahuna integration APIs here, for example: launchWithKey, loginWithCredentials and so on
        // Add your app initialization code here
        return YES;
  3. Implement the delegate kahunaInAppMessageReceived, which is invoked when your app receives an in-app message.

    - (void)kahunaInAppMessageReceived:(NSString *)message withDictionary:(NSDictionary *)extras
       NSLog(@"Received In-App Message from Kahuna!");
       // Display your in-app message here
       // Message will have the text you can display in the body of your in-app message
       // Extras will contain any deep-linking parameters included in the in-app message

Optional - Sample UI Code

The SDK provides sample, open source, UI code that you can use as a starting point for displaying in-app messages. You can customize this UI code to suit your needs.

  1. Include the files KahunaInAppMessageView.h and KahunaInAppMessageView.m in your codebase.
  2. Add the following code to your kahunaInAppMessageReceived delegate.

    #import <Kahuna/KahunaInAppMessageView.h>
    - (void)kahunaInAppMessageReceived:(NSString *)message withDictionary:(NSDictionary *)extras
       NSLog(@"Received In-App Message from Kahuna!");
       KahunaInAppMessageView *kView = [[KahunaInAppMessageView alloc]
                                onView:[[[UIApplication sharedApplication] windows] objectAtIndex:0]


In the above sample code, the KahunaInAppMessageView takes a few parameters that you can customize depending on the needs of your application:

initToShow OnTop, InCenter, or OnBottom - the 3 different message locations. You can use deep-linking parameters to control this in your app.
withImage The NSData object representing an image that the template will show in the in-app message. For example, you can use NSURLConnection to download an Image Url sent as a deep-linking parameter.
withDeepLink The sample template shows a Go button if there are any deep-linking parameters sent with the in-app message. Modify the template to take the user to a specific view in your app that is relevant to the in-app message.

To track Custom In-App Messages (clicks, dismisses, displayed, and not displayed events) just like marketer-driven in-app messages, please also implement the events described on Configuring Kahuna Integration To Track Custom In-App Message Events.

After you complete the steps in this topic, your AppDelegate is ready to start receiving custom in-app messages from Kahuna. Now, follow the steps in Add Attributes and Events.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request