Kongregate Developers

Note: This feature will not function unless we have enabled it for your game. If you would like to have this feature enabled, please contact us.

Conditionally initializing the native API

If you will not be making a different build of your game exclusively for Kongregate, then it can be helpful to be able to determine at runtime whether or not to use the Kongregate API. In general, you will want to enable the Kongregate API if the game was installed from the game page on Kongregate, and you can disable it otherwise.

Determining if an install came from Kongregate

When you are ready to publish your game with the Native API, Kongregate will generate and host a small custom installer on your Kongregate game page. When users launch the installer, it will download and install the Kongregate Client if needed, and then download and launch your game's original installer with an extra command-line parameter: -from-kongregate=true. Your setup program should detect this flag, and if it is found you should write something to persistent storage such as a configuration file or the registry indicating that the Kongregate API should be enabled.

When your game is launched, you should check for the flag that you put in place during the installation process and use that to determine whether or not to initialize the Kongregate API.

Below is a simple diagram outlining this process:

Using this flow, you can easily use the same game client for both Kongregate and non-Kongregate installations. It is generally a good idea to remove this flag during the application's uninstall process, as well.

What if I can't modify the setup program?

While adding the Kongregate detection process into your game's installer is likely the easiest way to enable dynamically initializing the API, there are other methods that can be used if modification is not possible.

One method would be to simply check for the existence of the Kongregate Client the first time the game is launched. If the client is installed, then you would set a flag somewhere in persistent storage to indicate that the Kongregate API should be enabled, otherwise, set the flag to false and allow your game to behave as it normally would without using the Kongregate API.

Below is a basic outline of how such a process might work:

Customizing the experience

The API also provides functionality to allow you to fully customize any aspect of this to the user by detecting the presence of the Kongregate Client. For example, if you detect the client is not installed you could show your normal login user interface, but also place a Kongregate button which initializes the API and allows users to sign in using their Kongregate account.