Xcode Setup

  1. Drag 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. Drag AdjustSDK.framework, Swrve.framework and Swrve.bundle to your project. These files should now exist in you Linked Frameworks and Libraries and Cop Bundle Resources sections, respectfully.
  3. Add the iOS Frameworks to your project:
    • Accounts.framework
    • AddressBook.framework
    • AdSupport.framework
    • AssetsLibrary.framework
    • AVFoundation.framework
    • CFNetwork.framework
    • CoreData.framework
    • CoreLocation.framework
    • CoreTelephony.framework
    • GameKit.framework
    • iAd.framework
    • MessageUI.framework
    • QuartzCore.framework
    • SafariServices.framework
    • Security.framework
    • SystemConfiguration.framework
    • StoreKit.framework
    • UIKit.framework
  4. Add the following to your .pch file to make the KongregateSDK available to all your files: #import <KongregateSDK/KongregateSDK.h>
  5. 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 once early in your application. See Events and Analytcs for more details handling Kongregate API events and using the Analytics API.

Update the values in the map below with those provided by your Kongregate producer.

// Set api options.
// Most apps will enable Swrve and Adjust
NSDictionary* apiSettings = @{
    KONGREGATE_OPTION_SWRVE_APP_ID: @123,
    KONGREGATE_OPTION_SWRVE_API_KEY: @"MySwrveApiKey",
    KONGREGATE_OPTION_ADJUST_APP_TOKEN: @"MyAdjustAppToken",
    KONGREGATE_OPTION_ADJUST_ENVIRONMENT: @"sandbox",
    KONGREGATE_ADJUST_SALE_EVENT_TOKEN: @"MySaleEventToken",
    KONGREGATE_ADJUST_SESSION_EVENT_TOKEN: @"MySessionEventToken",
    KONGREGATE_ADJUST_INSTALL_EVENT_TOKEN: @"MyInstallEvenToken",
};

// Initialize the API
__int64_t kongregateGameId = 123456; // Replace with your ID
[KongregateAPI initialize:kongregateGameId apiKey:@"MyKongregateAPIKey" withSettings:apiSettings];
KongregateAPI * api = KongregateAPI.instance;

// Set up an event listener
[api setApiEventListener:self selector:@selector(onKongregateApiEvent:)];

// Setup analytics event callback. This is how you pass common fields along with Keen/Swrve events
[[[KongregateAPI instance] analytics] setCommonPropertiesBlock:^NSDictionary *{
        return @{ @"tuturial_completed": tuturialCompleted,
                  @"soft_currency_balance": sofCurrencyBalance,
                  @"hard_currency_balance": hardCurrencyBalance };
}];

Event Callbacks

You should set a callback listener for processing Kongregate events.

// Assuming: -(void)myKongregateListener:(NSString *)event;
[[KongregateAPI instance] setApiEventListener:self selector:@selector(myKongregateListener:)];

User info & Services

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

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

Mobile control & button

// 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