SDK v3.2.0 removes DeltaDNA. See Upgrading from 3.0/3.1 for more information.
SDK v3.1.4 Includes a fix for Adjust Uninstall and Reinstall Tracking for iOS 13
SDK v3.1.2 Includes an Adjust Upgrade with support for Uninstall and Reinstall Tracking.

Unity Editor Setup

  1. In Unity, select Assets -> Import Package -> Custom Package… Find and select kongregate-sdk-x.x.x/Unity/Kongregate.unitypackage and select all files.
    • You may receive some warnings about images/textures/PNG files during the import. You can ignore these.
  2. Create an Empty Game Object named Kongregate, attach the KongregateInit.cs script. In the Unity Inspector, drag the kong-config.json you received with your welcome email into the JSON Config property.

Note: older methods of initialize the Kongregate SDK by following the KongregateGameObject-Example.cs or using the KongregateManager.cs script are still supported.

Demo Scripts

The Assets/Plugins/Kongregate/demo directory contains a handful of scripts that demonstrate various aspects our the Kongregate SDK.

Unity Android Setup

Below are extra steps required for Android builds.

Shared Secret Provider

Most Kongregate games support Shared Sign-on meaning when you log into one Kongregate Game you automatically log into other Kongregate Games without needing to re-enter a username and password. To support this on Android your game must:

  1. Be signed using Kongregate’s certificate (see Mobile Build System)
  2. Define a Shared Secret Provider and the custom ReadSharedData2 permission as described below.

Use the Shared Secret Provider Generator tool to generate a Shared Secret Provider class and retrieve the entries that must be added to /Assets/Plugins/Android/AndroidManifest.xml. If this file doesn’t exist, you can copy the base one from Unity /Applications/Unity/PlaybackEngines/AndroidPlayer/Apk/AndroidManifest.xml.

Select Tools -> Kongregate Tools -> Shared Secret Provider Generator, Click Generate Provider and follow the instructions in the Text Box:

Provider Generator

Copy the <provider>, <permission>, and <uses-permissions> tags out of the text box and past them into your AndroidManifest.xml. Be sure the resulting android:name and android:authority follow the format com.kongregate.android.api.[YourGame]SharedSecretProvider. This name must be unique across all Kongregate games.

If you have problems with the tool, you may use the providerbuilder ant script instead. Contact mobile-dev@kongregate.com if you have any trouble with these tools.

Google Referrer API

Kongregate and Adjust SDKs require the installreferrer, play-services-ads-identifier, and support-v4 libraries. If your game uses Google Play Game Services Unity Plugin then you should be all set. Our plugin includes /Assets/Kongregate/Editor/Dependencies.xml which is read and resolved by the PlayServicesResolver included with the Google Play Services Plugin. If you disabled auto-resolve, you may need to run Assets->Play Services Resolver->Android Resolver->Resolver. If you are not using the Google Play Services Plugin and need to pull over these archives, you can find Adjust Instruction’s Here.

Unity iOS Setup

The unitypackage includes /Assets/Editor/KongregatePostProcessor.dll that will perform all the required modifications to the XCode project at build time. If this post-processor interferes another post-processor your projects uses, you may need to disable it by removing the KongregatePostProcessor.dll file and performing the following steps when you build the XCode project.

  1. Make sure the KongregateSDK and dependencies are added to the Xcode project. Drag the following files Assets/Editor into the generated XCode project.

     AdjustSDK.framework
     KongregateUnityWrapper.framework
     KongregateSDK.framework
     KongregateSDK.bundle
    

    The KongregateSDK.framework, KongregateUnityWrapper.framework and AdjustSDK.framework should now be in the Linked Frameworks and Libraries section of your projects General Build Settings. The KongregateSDK.bundle should now be in the Copy Bundle Resources section of your project’s Build Phases

  2. Add any missing dependent iOS frameworks to your project under General -> Linked Framworks and Libraries.

     Accounts.framework
     AdSupport.framework
     AddressBook.framework
     AssetLibrary.framework
     AVFoundation.framework
     CFNetwork.framework
     CoreData.framework
     CoreLocation.framework
     CoreTelephony.framework
     QuartzCore.framework
     GameKit.framework
     iAd.framework
     MessageUI.framework
     SafariServices.framework
     Security.framework
     StoreKit.framework
     SystemConfiguration.framework
     UIKit.framework
    
  3. Add the following linker flags under Build Settings -> Linking -> Other Linker Flags

     -lz
     -ObjC
    

Unity Web Setup

Please see the web integration documentation for information on Unity web player builds.

Initialization

The KongregateInit.cs script you attached to the Kongregate Game Object will handle initializing the Kongregate and Adjust SDKs using settings from kong-config.json. This JSON file contains various API keys and IDs needed to initialize the SDK.

To track the common fields sent with all analytics events, you will need to use KongregateInit.SetCommonPropsCallback() to set a callback that returns a Dictionary of all fields that should be included with every event. From your games schema, this includes events in the Common Fields table with SDK Input set to Callback. The fields listed as Auto are automatically fired by our SDK. This should be set as soon as possible.

  using Kongregate;

  public class MyGameObjectScripe : MonoBehaviour {

    void Start() {
      KongregateInit.SetCommonPropsCallback(CommonPropsCallback);
    }
  }

The kong-config.json includes a ReleaseCandidate setting and DeferAnalytics setting both set to false by default. When ReleaseCandidate is set to true, events will be sent to production data streams for Adjust and Kongregate. During development, you typically want to leave this false to prevent corrupting live data. On Android you will see some Toast warning while running in sandbox mode (ReleaseCandidate is false). This is simply to help QA catch sandbox builds before they go live.

You may also control release candidate builds by setting a RELEASE_CANDIDATE scripting define symbol. When set, this will take precedence over the value in kong-config.json. Use whichever method fits better with your build pipeline.

Deferred Analytics allows you to delay sending events until your game has all information it needs to populate common properties. See Analytics for more details.

See KongregateConfig for the list of settings that may be parsed from kong-config.json file.

If you need to modify less common settings for our SDK, you may extend the KongregateInit.cs class and override KongregateInit.ConfigureAPISettings to set the additional settings.

  public class MyGameInit : KongregateInit {
    override protected void ConfigureAPISettings() {
      base.ConfigureAPISettings();

      // Change the transition used when opening the panel.
      KongregateAPI.Settings.DefaultPanelTransition = Kongregate.Mobile.PANEL_TRANSITION_SLIDE_FROM_LEFT;
    }
  }

Event Callbacks

You may set listeneters for the various events fired by KongregateInit. See Kongregate events for more detail on when each event is fired.

User info & Services

You may access various information about the user.

KongregateAPI api = KongregateAPI.GetAPI();
string username = api.Services.GetUsername();
string authtoken = api.Services.GetGameAuthToken();
bool isguest = api.Services.IsGuest();

Statistics, Scores & Achievements

You may submit statistics through the client, if you game supports Kongregate Achievements. This may also be done server-to-server using our REST API.

KongregateAPI.GetAPI().Stats.Submit("HighScore", 1);

Mobile control & button

You may either let the button draw natively, or manually open the kongregate panel

//configure up our button
kongregate.Mobile.ButtonSetNativeRendering(true); // true by default, false means render in Unity rather than native
kongregate.Mobile.ButtonSetX(10);
kongregate.Mobile.ButtonSetY(10);
kongregate.Mobile.ButtonSetSize(48);
kongregate.Mobile.ButtonShow();

// if our button is not hidden, we need to draw it
if (!kongregate.Mobile.ButtonIsHidden()) {
  if (kongregate.Mobile.ButtonIsNativeRendering()) {
    //nothing to do, rendering is handled in native SDK
  } else {
    // draw our button
    if (GUI.Button (kongregate.Mobile.ButtonGetRect(), kongregate.Mobile.ButtonGetTexture(), "label")) {
      Debug.Log ("You clicked the Kong button!");
      kongregate.Mobile.OpenKongregateWindow();
    }
  }

Unity API Docs & Usage

Unity API Documentation