Legacy (Pre-3.3) iOS Unity Integrations


Basic Integration

Fire up Unity and import the plugin files: Right-click Assets in the Project section, then mouse over Import Package and click Custom Package:

The C# files exposing the Chartboost SDK methods — ChartBoostBinding.cs and ChartBoostManager.cs — are located in the Chartboost directory (Assets > Plugins > Chartboost). The native SDK and objective-c wrapper files are located in the iOS directory (Assets > Plugins > iOS).

If you navigate to the new Demo directory (Assets > Plugins > Chartboost > Demo), you’ll see two C# scripts — ChartBoostGUIManager and ChartBoostEventListener. These scripts demonstrate how to hook up exposed methods from ChartBoostBinding.cs (for a basic integration) and ChartBoostManager.cs (to use delegate methods) in any of your scripts:

ChartBoostBinding.cs and ChartBoostManager.cs list all available Chartboost methods, which are also available for reference below.

ChartBoostBinding.cs exposes the following methods:

// Starts up Chartboost and records a bootup or install. Must not be dependent on prior network calls or user actions.
public static void init( string appId, string appSignature, bool shouldRequestInterstitialsInFirstSession = true )

// Caches an interstitial. Location is optional; pass in "null" if you don't want to specify one.
public static void cacheInterstitial( string location )

// Checks to see if an interstitial is cached
public static bool hasCachedInterstitial( string location )

// Shows an interstitial. Location is optional; pass in "null" if you don't want to specify one.
public static void showInterstitial( string location )

// Forces orientation of interstitials. (If your project is properly set up to auto-rotate, animated native views will work as expected, and you should not need to set this.)
public static void forceOrientation( ScreenOrientation orient )
Best Practices
  • Init and onStart only need to be called once per session; they should not be called again when switching scenes
  • A “session” includes both hard bootups and soft bootups — Init and onStart should be included in methods that will fire when the game first boots and each time it becomes active from the background

Advanced Integration

ChartBoostManager.cs fires the following events:

// Fired when an interstitial fails to load
public static event Action didFailToLoadInterstitialEvent;

// Fired when an interstitial is finished
public static event Action didDismissInterstitialEvent;

// Fired when an interstitial is closed
public static event Action didCloseInterstitialEvent;

// Fired when an interstitial is clicked
public static event Action didClickInterstitialEvent;

// Fired when an interstitial is cached
public static event Action didCacheInterstitialEvent;

Don’t make cache or show calls inside didFailToLoad delegates or the universe will implode.