I’ve recently switched from using Admob in my games to Chartboost. This switch made sense because most of the ads that were filling with Admob were not relevant to gaming. For example, many of the ads Turbo Prop was receiving were dating and real-estate related. This resulted in very poor eCPM.
The following is a great (and quick) way to get Chartboost ads for iOS and Android in your Unity3D 4.3+ game.
Start by downloading the latest Chartboost SDK from the official website. Extract the archive and import the package by going Assets -> Import Package -> Custom Package -> CBUnityPlugin.*.unitypackage. When prompted, choose to import everything.
By default, Android is not configured to use Chartboost. In order to use the Chartboost SDK for Android you must alter the ApplicationManifest.xml and import the Google Play Services library into your project. Luckily this can be done without effort by choosing Chartboost -> Android Setup from the toolbar. However, make sure you have the Android SDK installed and configured on your computer first.
using UnityEngine;
using System.Collections;
using Chartboost;
public class ChartboostSetup : MonoBehaviour {
void OnEnable() {
#if UNITY_ANDROID
//CBBinding.init("CB_APP_ID_ANDROID", "CB_APP_SIG_ANDROID");
CBBinding.init("4f7b433509b6025804000002", "dd2d41b69ac01b80f443f5b6cf06096d457f82bd");
#elif UNITY_IPHONE
//CBBinding.init("CB_APP_ID_IOS", "CB_APP_SIG_IOS");
CBBinding.init("4f21c409cd1cb2fb7000001b", "92e2de2fd7070327bdeb54c15a5295309c6fcd2d");
#endif
}
#if UNITY_ANDROID
void OnApplicationPause(bool paused) {
CBBinding.pause(paused);
}
void OnDisable() {
CBBinding.destroy();
}
#endif
void Start() {
CBBinding.showInterstitial(null);
}
void Update() {
if(Input.GetKeyUp(KeyCode.Escape)) {
if(CBBinding.onBackPressed()) {
return;
} else {
Application.Quit();
}
}
}
}
The above code is responsible for initializing Chartboost for Android and iOS, as well as showing an interstitial advertisement (graphical popup). Attach this script to a GameObject
on your scene in addition to attaching CBManager.cs to a different GameObject. CBManager
will make it possible for you to use the SDK on your scene.
By adding Chartboost to your Unity3D game you will get better targeted ads with higher eCPM in comparison to Admob.
To quickly view your Chartboost analytics, I’ve gone ahead and created a nifty mobile app called Admate for Chartboost. Please rate it 5 stars if you download it.