Follow

Advanced Usage - Selecting Interstitial Ad Type

View original article on our GitHub

When calling an interstitial ad, the ad type with the best performance will be automatically selected. If you would like to explicitly choose the type of ad, use theSTAInterstitialProperties.type object when calling loadAd().

The options for this parameter are:

Constant NameDescription
StartAppWrapperiOS.AdType.STAAdType_Automatic(recommended) Automatic selects the most suitable banner of the two listed below
StartAppWrapperiOS.AdType.STAAdType_FullScreen A full-page ad
StartAppWrapperiOS.AdType.STAAdType_OfferWall A full page offerwall
StartAppWrapperiOS.AdType.STAAdType_Overlay An overlay Ad is a full page Ad that runs on top of your application

We highly recommend using the Automatic type, which automatically selects the best ad type to display.

Example - loading an OfferWall ad

#if UNITY_IPHONE
StartAppWrapperiOS.STAInterstitialProperties adProp = new StartAppWrapperiOS.STAInterstitialProperties();
adProp.type = StartAppWrapperiOS.AdType.STAAdType_OfferWall;
StartAppWrapperiOS.loadAd(adProp);
#endif

Using Interstitial Callbacks

Use one of your GameObjects as a delegate to get callbacks from the interstitial ad. Even an empty GameObject you create for this purpose will do.

  1. Pass the GameObject name on the STAInterstitialProperties.delegateNamemember to the loadAd() method

    void Start () {
          #if UNITY_IPHONE
          StartAppWrapperiOS.STAInterstitialProperties adProp = new StartAppWrapperiOS.STAInterstitialProperties();
          adProp.delegateName ="Main Camera";
          StartAppWrapperiOS.loadAd(adProp);
          #endif    
    }
  2. Implement the following callbacks in your GameObject script

    public class StartAppGameObject : MonoBehaviour {
    // Use this for initialization
    void Start () {
        #if UNITY_IPHONE
        StartAppWrapperiOS.STAInterstitialProperties adProp = new StartAppWrapperiOS.STAInterstitialProperties();
        adProp.delegateName ="Main Camera";
        StartAppWrapperiOS.loadAd(adProp);
        #endif    
    }
    
    void didLoadAd() {
        #if UNITY_IPHONE
        Debug.Log("didLoadAd");
        #endif    
    }
    void failedLoadAd(string Error) {
        #if UNITY_IPHONE
        Debug.Log("failedLoadAd");
        #endif
    }
    void didShowAd() {
        #if UNITY_IPHONE
        Debug.Log("didShowAd");
        #endif    
    }
    void failedShowAd(string Error) {
        #if UNITY_IPHONE
        Debug.Log("failedShowAd");
        #endif    
    }
    void didCloseAd() {
        #if UNITY_IPHONE
        Debug.Log("didCloseAd");
        #endif    
    }
    void didClickAd() {
        #if UNITY_IPHONE
        Debug.Log("didClickAd");
        #endif    
    }
    }

Checking if ad is ready

You can check if your ad is loaded and ready to use, by using the isAdReady() method:

#if UNITY_IPHONE
StartAppWrapperiOS.isAdReady();
#endif 

 

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

Comments