Showing Interstitial Ads

View original article on our GitHub

You can choose to show the interstitial ad in several locations within your application. This could be between stages, while waiting for an action, when pressing a button and more.

First, import the StartApp SDK in your view controller and add the following lines to the cpp file for each view in which you would like to show an ad

// HelloWorldScene.cpp

#include "StartAppPlugin.h"

bool HelloWorld::init()
    startappiOS* startAppBridge =  startappiOS().sharedInstance();
    return true;

Then, just add the following line where you want to show the ad


Loading an ad might take a few seconds so it's important to show the ad as late as you can. In case you call showAd() while the ad hasn't been successfully loaded yet, nothing will be displayed. For example, if you'd like to show an ad after completing a game's level, the best practice would be to show the ad upon completing the level (for example in your viewDidDisappear() function). On the other hand, loading and showing the ad together at the beginning of the next level might result with a failure – as the ad might not have enough time to load.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request