This plugin allows you to show interstitials using the Chartboost toolkit. Both iOS and Android targets are supported.
Check out the Chartboost Demo App to see the module in action.
Install the chartboost module into your application using the standard devkit install process:
devkit install https://github.com/gameclosure/chartboost#v2.1.0
Before you can use chartboost you must specify your game's AppID and
AppSignature from the chartboost dashboard. Edit the manifest.json "android" and "ios" sections to include
chartboostAppIDand
chartboostAppSignature` as shown below.
"android": {
"chartboostAppID": "51de21ed17ba477663000050",
"chartboostAppSignature": "079827b6a0e831ef37ead6a2334bc712f28f9a1f"
},
"ios": {
"chartboostAppID": "51de1c4f17ba47cd62000000",
"chartboostAppSignature": "4a86b060d0f5c17a34f48bedf49c8a63280607ce"
},
Note that the manifest keys are case-sensitive.
You can test for successful integration via the Chartboost website after successfully building and running your game on a network-connected device.
To start using Chartboost in your game, first import the chartboost object:
import chartboost;
The chartboost plugin provides methods that you can call to cause actions like preloading or displaying an ad (or video, or 'more apps' popup). These generally follow the same pattern of showThing, cacheThing, and showThingIfAvailable.
The chartboost plugin emits several events that your application can listen for to react to various states of the plugin. You do not need to do anything with these events unless you want to do some custom action (analytics, wait for cached ads, etc) when one of these events occurs. Some events overlap, like clicked/closed and dismissed - only listen for what you are interested in.
You can show interstitials by calling:
chartboost.showInterstitial();
To improve user experience, you can pre-load and cache interstitial ads by first calling:
chartboost.cacheInterstitial();
The chartboost plugin also provides a helper function that will show an interstitial, but only if one is cached:
chartboost.showInterstitialIfAvailable();
AdAvailable
- emitted when an ad has been cached and is ready to be
shown
AdFailedToLoad
- emitted when an ad fails to load from the
chartboost servers
AdDisplayed
- emitted when an ad is shown to a user
AdDismissed
- emitted when an ad goes away, either from the user
clicking it or closing it
AdClosed
- emitted when an ad is closed by the user
AdClicked
- emitted when an ad is clicked by the user
Example:
chartboost.on('AdClicked', function () { logger.log('user clicked an ad!'); });
Control the 'more apps' feature in the same way as interstitial ads:
// show 'more apps' now, regardless of cache
chartboost.showMoreApps();
// load and cache 'more apps' for displaying later
chartboost.cacheMoreApps();
// display 'more apps' if one has been cached
chartboost.showMoreAppsIfAvailable();
MoreAppsAvailable
- emitted when a 'more apps' dialog is ready
MoreAppsFailedToLoad
- emitted when a 'more apps' fails to load from
the chartboost servers
MoreAppsDisplayed
- emitted when a 'more apps' is shown to a user
MoreAppsDismissed
- emitted when a 'more apps' goes away, either
from the user clicking it or closing it
MoreAppsClosed
- emitted when a 'more apps' is closed by the user
MoreAppsClicked
- emitted when a 'more apps' is clicked by the user
Example:
chartboost.on('MoreAppsClicked', function () {
logger.log('user clicked on more apps!');
});
Control the rewarded video feature in the same way as interstitial ads, with the
addition of the RewardedVideoCompleted
event.
// show rewarded video now, regardless of cache
chartboost.showRewardedVideo();
// load and cache rewarded video for displaying later
chartboost.cacheRewardedVideo();
// display rewarded video if one has been cached
chartboost.showRewardedVideoIfAvailable();
RewardedVideoAvailable
- emitted when a rewarded video dialog is ready
RewardedVideoFailedToLoad
- emitted when a rewarded video fails to load from
the chartboost servers
RewardedVideoDisplayed
- emitted when a rewarded video is shown to a user
RewardedVideoDismissed
- emitted when a rewarded video goes away, either
from the user clicking it or closing it
RewardedVideoClosed
- emitted when a rewarded video is closed by the user
RewardedVideoClicked
- emitted when a rewarded video is clicked by the user
RewardedVideoCompleted
- emitted when a rewarded video is completed
Example:
chartboost.on('RewardedVideoCompleted', function (reward) {
logger.log('user completed rewarded video', 'reward: ', reward);
});
The chartboost plugin is currently using version 5.1.3 of the chartboost SDK on both android and ios.
NOTE: On ios, their SDK directory structure has been slightly changed to remove the symlinks they ship with and delete the extra Versions folder (leaving it like a standard framework folder with Chartboost and Headers at the top level). If you change the SDK, you will likely need to repeat the above change.
Check out the chartboost demo app for a working example.