Fullscreen Ad Queue
Ad queueing is available in Chartboost Mediation 4.9.0 and later. It allows queueing of multiple fullscreen ads to show in succession. This can reduce and potentially eliminate latency for ad experiences that require showing fullscreen ads back to back.
IFullscreenAdQueue π
IFullscreenAdQueue manages the pre-loading of fullscreen ads. Each IFullscreenAdQueue manages ads for one placement. To create a IFullscreenAdQueue object call ChartboostMediation.GetFullscreenAdQueue as seen in the example below:
IFullscreenAdQueue adQueue = ChartboostMediation.GetFullscreenAdQueue("PLACEMENT_NAME");
Keywords π
Keywords are key-value pairs to enable real-time targeting on line items. Every load request made by the IFullscreenAdQueue object will include these keywords. To remove keywords, pass a new set without those keywords. The list will be overridden. This is to facilitate the wrapping process between Unity and native platforms.
...
// Keywords to pass for IFullscreenAdQueue
var keywords = new Dictionary<string, string>
{
{ "key", "value" },
{ "key_2", "value_2" }
};
// assign Keywords to IFullscreenAdQueue
adQueue.Keywords = keywords;
Usage Example π
// Get Queue
IFullscreenAdQueue queue = ChartboostMediation.GetFullscreenAdQueue("PLACEMENT_NAME");
Debug.Log($"Queue capacity : {queue.QueueCapacity}");
// Monitor Queue
queue.DidUpdate += (adQueue, adLoadResult, numberOfAdsReady) => Debug.Log($"Queue Updated. NumberOfAdsReady : {numberOfAdsReady}");
queue.DidRemoveExpiredAd += (adQueue, numberOfAdsReady) => Debug.Log($"Removed expired ad. NumberOfAdsReady : {numberOfAdsReady}");
// Start queue
queue.Start();
// Wait for some time for the queue to load an ad or subscribe to `DidUpdate`
// event as shown above to be notified when an ad is loaded into queue
// Load an ad from queue
if (queue.HasNextAd())
{
// removes and returns the oldest ad in the queue
// and starts a new load request
var fullscreenAd = queue.GetNextAd();
}
// The dashboard's queue size settings can be overridden at runtime.
// If this placement has a Queue Size setting of 2 and Max Queue Size
// is 4 or 5, this line of code will increase this queue's size to
// 4. But if Max Queue Size is smaller than the number passed to
// setQueueCapacity, the queue size will only be increased up to the
// allowed maximum. So if Max Queue Size is 3 then an error message
// will be logged and this queue's size will be changed to 3.
queue.SetCapacity(4);
// Stop queue
queue.Stop();
// Keywords can be set at any time, whether the queue is stopped or running.
// The next ad request sent by the running queue will use the keywords set here.
queue.Keywords = new Dictionary<string, string>()
{
{ "key", "value" }
};