Overview

The following steps outline how to integrate the Kongregate SDK and Adjust into your game. Note many games only need to integrate the Analytics portions of the SDK. That is, they do not use Kongregate for authentication or the Kongregate Panel to integrate with features from kongregate.com (i.e. forums, badges, etc). Steps labeled FULL INTEGRATION ONLY may be skipped if you are only integrating with Kongregate and Adjust Analytics.

Xcode Project Setup

  1. Drag AdjustSDK.framework, KongregateSDK.framework and KongregateSDK.bundle to your project:
    • KongregateSDK.framework should now be in the Linked Frameworks and Libraries section of your projects General Build Settings
    • KongregateSDK.bundle should now be in the Copy Bundle Resources section of your projects Build Phases
  2. Add the iOS Frameworks to your project:
    • Accounts.framework
    • AdSupport.framework
    • AVFoundation.framework
    • CFNetwork.framework
    • CoreData.framework
    • CoreTelephony.framework
    • GameKit.framework
    • iAd.framework
    • MessageUI.framework
    • QuartzCore.framework
    • Security.framework
    • StoreKit.framework
    • UIKit.framework
  3. Add -lz and -ObjC to your project’s Build Settings -> Linking -> Other Linker Flags.
    • -lz links with zlib which the SDK uses to zip/unzip some data.
    • -ObjC ensures Objective-C classes and categories are loaded, which is required by the Adjust SDK.

Initialization

The Kongregate API should be initialized soon after your game launches. UIApplicationDelegate application:didFinishLaunchingWithOptions: is a good spot.

Replace the option values below with values included with your welcome email. NOTE: KONGREGATE_OPTION_KONG_ANALYTICS_KEY and KONGREGATE_OPTION_ADJUST_ENVIRONMENT have different values for test/dev and live/rc builds.

#import <KongregateSDK/KongregateSDK.h>

// Set api options.
// Most apps will enable Swrve and Adjust
NSDictionary* apiSettings = @{
  KONGREGATE_OPTION_KONG_ANALYTICS_KEY: @"you-kong-analytics-key",
  KONGREGATE_OPTION_KONG_ANALYTICS_ID: @"/studio/game-name/dev",
  KONGREGATE_OPTION_ADJUST_APP_TOKEN: @"abcdef123456",
  KONGREGATE_OPTION_ADJUST_ENVIRONMENT: @"sandbox",
  KONGREGATE_ADJUST_SALE_EVENT_TOKEN: @"abcdef",
  KONGREGATE_ADJUST_INSTALL_EVENT_TOKEN: @"ghijkl",
  KONGREGATE_ADJUST_SESSION_EVENT_TOKEN: @"mnopqr"
};

Analytics only integrations should initialize the API with the Activity and API Options Map only (values for gameId and apiKey should be 0L and nil`).

// initialize the API for Analytics only integrations
[KongregateAPI initialize:0L apiKey:nil withSettings:apiSettings];

Full integrations will also pass a game ID and Mobile API key to the initialization method.

// initialize the API for full Kongregate and Analytics integrations
[KongregateAPI initialize:gameCode apiKey: withSettings:apiSettings];

Set the CommonPropertiesEvaluator to retrieve properties from your game to included with all events. The fields to include are detailed in the schema provided in the integration welcome email. Entries with Table Name COMMON FIELDS and SDK Input as Callback should be returned by your callback.

This is required for all integrations.

[[[KongregateAPI instance] analytics] setCommonPropertiesBlock:^NSDictionary *{
        return @{ @"tuturial_completed": tuturialCompleted,
                  @"soft_currency_balance": sofCurrencyBalance,
                  @"hard_currency_balance": hardCurrencyBalance };
}];

FULL INTEGRATIONS should also register a listener for Kongregate Events

// register to listen for Kongregate events.
[api setApiEventListener:self selector:@selector(onKongregateApiEvent:)];

See Events for more details handling Kongregate API events.

Sending Events

Analytics only integrations may find details on sending events on the Analytics Only Events Page.

FULL INTEGRATIONS may find details on the analytics system in the Main Analytics Page.

User info & Services

FULL INTEGRATION_ONLY

bool isGuest = KongregateAPI.instance.services.isGuest;
NSString* username = KongregateAPI.instance.services.getUsername;
NSString* authToken = KongregateAPI.instance.services.getGameAuthToken;
__int64_t userId = KongregateAPI.instance.services.getUserId;

Statistics, Scores & Achievements

FULL INTEGRATION_ONLY

[[[KongregateAPI instance] stats] submit:@"HighScore" value:1];

Mobile control & button

FULL INTEGRATION_ONLY

// Call to get a UIButton
UIButton * button = [[[KongregateAPI instance] mobile] getButton];

// Open the kongregate window
[[[KongregateAPI instance] mobile] openKongregateWindow];

API Docs & Usage

View API Documentation