=== Chartboost === [[http://www.chartboost.com|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 to 3.1.1 and is supported on iOS and Android. Requires an [[http://www.rtsoft.com/wiki/doku.php?id=proton:admanager|AdManager]] object to be setup to use. === Adding Chartboost to the AdManager === * Add /shared/Ad/AdProviderChartBoost.cpp to your project (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("", ""); 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 and 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: #define RT_CHARTBOOST_ENABLED 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: === Enabling Chartboost for Windows Android build === 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 //#define RT_CHARTBOOST_SUPPORT to enable it. One last thing. Edit your android/AndroidManifest.xml and add the following somewhere for chartboost: 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. === Enabling Chartboost for your iOS xCode build === First, download the [[http://www.chartboost.com/support/sdk|Chartboost iOS SDK]] and put the contents in /shared/iOS/ChartBoost. (The directory will already exist) * Add the file /shared/Ad/AdProviderIOS_ChartBoost.mm to your xCode project * Add the file /shared/iOS/ChartBoost/libChartboost.a to your xCode project * Add the file /shared/iOS/ChartBoost/Chartboost.h to your xCode project * Make sure RT_CHARTBOOST_ENABLED is being defined somewhere (either in the xcode preprocessor macros, or App.h) If you compile and see an Apple Mach-O Linker error of _SCNetworkReachabilityCreateWithAddress then you need to do the following: * Add the SystemConfiguration.framework to your xCode project. (One way is to click + on the Link Binary With Libraries dialog under Build Phases, then find it in there) If you compile and see an Apple Mach-O Linker error of _CFStreamCreatePairWithSocketToCFHost, then you need to do the following: * Add the CFNetwork.framework to your xCode project. (One way is to click + on the Link Binary With Libraries dialog under Build Phases, then find it there) **NOTE**: As of 12/2/2012, you must also "weak link" to the AdSupport and StoreKit frameworks, and be using the iOS 6.X sdk as the base sdk. (runs on iOS 4.3 or higher) If you don't, it looks like it works but it doesn't show ads. The debug output will tell you that you need to link the libs though.