iOS Swift Integration Guide

Introduction

Follow this guide to integrate our SDK into your Swift environment.

Getting Started

First, make sure you’re registered for a developer account at app.kiip.me. Adding an app to your developer account will issue an app key and secret necessary to integrate the Kiip SDK.

Integrate Kiip

If you don’t have a bridging header, make sure to create one.

Mix and Match

Make it look something like this:

#import <UIKit/UIKit.h>
#import <KiipSDK/KiipSDK.h>

Add the Necessary Frameworks

Before you compile and build, do the following:

  1. Drag in the KiipSDK.framework from the Kiip SDK folder to your frameworks section.

  2. Drag in the KiipSDKResources.bundle to your resources section. This is located inside the KiipSDK.framework directory.

  3. Link the following frameworks inside your Build Phases:

    • CoreTelephony.framework
    • QuartzCore.framework
    • SystemConfiguration.framework
    • AdSupport.framework
    • Passkit.framework
    • MediaPlayer.framework

Initialize Kiip

Now that you can compile this without any Kiip code, let’s initialize the Kiip singleton inside your AppDelegate.swift file. Navigate to the didFinishLaunchingWithOptions method. It should look like the following:

class AppDelegate: UIResponder, UIApplicationDelegate, KiipDelegate {

    let KP_APP_KEY: String = "Insert-your-app-key"
    let KP_APP_SECRET: String = "Insert-your-app-secret"

    func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
        var kiip: Kiip = Kiip(appKey: KP_APP_KEY, appSecret: KP_APP_SECRET)
        kiip.delegate = self
        Kiip.setSharedInstance(kiip)
        return true
    }
}

Build and voila! You’ve successfully integrated Kiip into your Swift application.

Call a Kiip Moment

Now that the hard part is done, the next step is figuring out where you want to reward users. In test mode (the iOS Simulator is always test mode), you will receive a test reward for every moment call. It’s better to place more reward moments in your code now as you can control whether or not they are rewardable later without having to submit an update.

Find a good place to reward a user and try the following:

Kiip.sharedInstance().saveMoment("beating level one!" withCompletionHandler: {(poptart:KPPoptart!, error:NSError!) -> Void in
    if error {
        /* handle error */
    }

    if !poptart {
        /* handle case with no reward to give*/
        println("Successful moment call but no reward to give.")
    }

    if poptart {
        poptart.show()
    }
})

Rewarding Virtual Currency

In case you’d like to give users your virtual currency as a reward, we’d recommend the following callback method inside where your KiipDelegate is set.

func kiip(kiip:Kiip, contentId:NSString, quantity:Int, transactionId:NSString, signature:NSString) {
    // Add quantity amount of content to player's profile
    // e.g +20 coins to user's wallet
}

NOTE: Make sure virtual currency is enabled inside your dashboard.

Rewarded Video

Access more inventory, increase engagement and drive more revenue with Rewarded Video. To utilize Rewarded Video, designate and individual moments placement in the Kiip dashboard.

Kiip Rewarded Video Moment

Sample Applications

In case you’d like to see code example projects, we have that as well. Navigate to our Github repo and check out our Swift examples.

Need Help?

We’re happy to answer any questions about integrating Kiip. Check out our FAQ or email us.