This is an old revision of the document!
Chartboost lets you tell your users about other games you've written by showing them big splash ads in a controlled way. You can specify that an ad is only shown once, or every day, or whatever. It's also possible to run ads for pay and track installs and bootups.
The AdManager Chartboost module has been tested with V3.01 and is supported on iOS and Android.
Requires an AdManager object to be setup to use.
(Yes, it should be Chartboost and not ChartBoost but don't make me change it, svn makes it a hassle and it's already used in client projects that would break with this change..)
Add the following under your other #include's near the top of App.cpp:
#ifdef RT_CHARTBOOST_ENABLED #include "Ad/AdProviderChartBoost.h" #endif
Note, the #ifdefs I use are not really required here, but it's useful so you can turn on/off different ad systems easily for specific builds or platforms.
Next, add the following code under the existing m_adManager.Init() statement. (You did already setup AdManager, right?!)
#ifdef RT_CHARTBOOST_ENABLED AdProviderChartBoost *pProvider = new AdProviderChartBoost; pProvider->SetupInfo("<insert chartboost appID>", "<insert chartboost appsignature>"); m_adManager.AddProvider(pProvider); pProvider->CacheShowInterstitial(); //optional, but helps pProvider->CacheShowMoreApps(); //optional but helps //if you want to show an ad, do this: m_adManager.GetProviderByType(AD_PROVIDER_CHARTBOOST)->ShowInterstitial(); //If you want to show the Chartboost more apps page, do this somewhere else in your app: //m_adManager.GetProviderByType(AD_PROVIDER_CHARTBOOST)->ShowMoreApps(); #endif
Note: You'll need to replace the <chartboost id> and <insert chartboost appsignature> parts with the stuff you cut and paste from the Chartboost portal.
In your App.h, add the following somewhere so Chartboost will actually be used:
Great. But it should compile on Windows and pretend like it's working, but it isn't doing anything. To actually test it, you'll need to do an iOS or Android compile and setup the chartboost libraries. Here is how:
These directions assume you are using the proton v2 android build system, which nearly all examples use now. You can look at RTAdManager for an example if needed.
First, download the Chartboost SDK files (you'll need a Chartboost account to see that option) and place chartboost.jar in the \shared\android\optional_src\libs\ChartBoost, which should exist already. I can't include this file in p+ for legal reasons.
* Add -DRT_CHARTBOOST_ENABLED to the SHARED_FLAGS variable in your /android/jni/Android.mk file, in case it isn't defined in your App.h * Make sure shared/Managers/AdManager.cpp, shared/Ad/AdProvider.cpp, and shared/Ad/AdProviderChartBoost.cpp are added to your /android/jni/Android.mk file
In your build_prepare.bat, you should see this somewhere already:
:for Chartboost (comment out the goto if you want to use it) :goto skipchartboost; set TEMPFILE=..\..\shared\android\optional_src\libs\ChartBoost\chartboost.jar :Extra check to make sure we can locate the files if exist "%TEMPFILE%" ( echo Located Chartboost files. ) else ( echo Cannot find the ChartBoost .jar file. Download and place lib into shared\android\optional_src\libs\ChartBoost ..\..\shared\win\utils\beeper.exe /p ) copy %TEMPFILE% libs :skipchartboost
Change “:goto skipchartboost;” to “goto skipchartboost;”, this will cause the charboost.jar file to get copied to libs during the build process.
Next, edit your android/src/Main.java and change
// #define RT_CHARTBOOST_SUPPORT
to enable it.
One last thing. Edit your android/AndroidManifest.xml and add the following somewhere for chartboost:
<!-- CHARTBOOST START --> <activity android:name="com.chartboost.sdk.CBDialogActivity" android:configChanges="orientation|keyboard|keyboardHidden" android:windowSoftInputMode="adjustResize" android:theme="@android:style/Theme.Translucent" android:screenOrientation="landscape" android:launchMode="singleTop" > </activity> <!-- CHARTBOOST END -->
That's it, Chartboost should work in your Android build now. Please note though, that unless you've setup an ad and a “campaign” in the Chartboost portal, nothing will show and you won't even know that it is working.
First, download the Chartboost iOS SDK and put the contents in /shared/iOS/ChartBoost. (The directory will already exist)
If you compile and see an Apple Mach-O Linker error of _SCNetworkReachabilityCreateWithAddress then you need to do the following:
If you compile and see an Apple Mach-O Linker error of _CFStreamCreatePairWithSocketToCFHost, then you need to do the following: