This RoboPod requires you to download and add the native 3rd party framework manually:
- Download the SDK from https://answers.chartboost.com/hc/en-us/articles/201220095
- Put the
Chartboost.framework
folder in your iOS project'slibs/
folder - Add the following to your
robovm.xml
<config>
...
<frameworkPaths>
<path>libs</path>
</frameworkPaths>
<frameworks>
<framework>Chartboost</framework>
</frameworks>
</config>
Add the following dependency to your build.gradle
:
dependencies {
... other dependencies ...
compile "org.robovm:robopods-chartboost-ios:$robopodsVersion"
}
Add the following dependency to your pom.xml
:
<dependency>
<groupId>org.robovm</groupId>
<artifactId>robopods-chartboost-ios</artifactId>
<version>${robopods.version}</version>
</dependency>
Before you can display any ads, you have to setup the SDK.
Add the following code to your application's entry point, typically didFinishLaunching()
in your app delegate.
Chartboost.start("APP_ID", "APP_SIGNATURE", delegate);
Change the APP_ID
and APP_SIGNATURE
with your app specific data that you can find in the
Chartboost dashboard. You can also specify a delegate if you want to listen for
certain events, like ad display or failures.
- Make sure you have setup an app in your Chartboost dashboard and specified the correct
APP_ID
andAPP_SECRET
. - Check your logs for any errors, like network failures.
- Load and display advertisements in your app: Link
- Read the official Chartboost iOS documentation: Link
Cache and display ads.
To show a static or interstitial video ad add the following code:
Chartboost.showInterstitial(CBLocation.HomeScreen);
The first method parameter tells Chartboost the location where the interstitial is shown in your game.
Note: Chartboost calls should always be made from the main - not background - thread: These calls may time out otherwise.
To show a rewarded video ad add the following code:
Chartboost.showRewardedVideo(CBLocation.HomeScreen);
The first method parameter tells Chartboost the location where the interstitial is shown in your game.
You should typically cache a video ad before displaying it:
Chartboost.cacheRewardedVideo(CBLocation.HomeScreen);
...
if (Chartboost.hasRewardedVideo(CBLocation.HomeScreen)) {
Chartboost.showRewardedVideo(CBLocation.HomeScreen);
} else {
// We don't have a cached video right now, but try to get one for next time
Chartboost.cacheRewardedVideo(CBLocation.HomeScreen);
}
If you want to reward your user after he watched the rewarded video, implement the required method in the delegate you specified when setting up the SDK:
new ChartboostDelegateAdapter() {
@Override
public void didCompleteRewardedVideo(String location, int reward) {
// Reward your user
}
}
Note: Chartboost calls should always be made from the main - not background - thread: These calls may time out otherwise.
Add the code where you want to see interstitials or video ads and run the app. You should always see at least test ads, if you setup everything correctly.
- Make sure you have started the Chartboost SDK: Link
- Make sure you call all Chartboost methods on the main thread.
- Check your logs for any errors, like network failures.