Skip to content

Unity Plugin Interstitial Integration

Eros edited this page Feb 12, 2021 · 8 revisions

Creating the Interstitial

The HyBidInterstitialAd should be created inside a script which is linked to a GameObject. It must be created using the HyBidInterstitialAdFactory createInterstitialAd() method which creates an interstitial based on the platform that the application is being built for.

public static HyBidInterstitialAd createInterstitial(MonoBehaviour parent) 

A sample of this instantiation is the following:

HyBidInterstitialAd interstitial = HyBidInterstitialAdFactory.createInterstitialAd(this);  

In the previous sample this is an object which inherits from MonoBehaviour so it’s linked to a GameObject.

After creating the Interstitial you must set the appToken and placement properties:

interstitial.appToken =App Token obtained from PubNative dashboard”;
interstitial.placement = “Placement Name configured and obtained from the PubNative Dashboard”; 

Setting the listener is also recommended to check the correct behaviour of the ads. You should implement the IInterstitialListener for HyBidInterstitialAd.

public interface IInterstitialListener
{
    void OnInterstitialLoaded ();

    void OnInterstitialLoadFailed (Exception error);

    void OnInterstitialImpression ();

    void OnInterstitialClick ();

    void OnInterstitialDismissed ();
}

Adding an InterstitialListener to the ** HyBidInterstitialAd** is mandatory since it will send callbacks when the ad was loaded or failed. After the ad is loaded then it can be displayed.

Here’s an implementation sample:

interstitial.InterstitialListener = INTERSTITIAL_LISTENER_INSTANCE;

Loading the interstitial

To load the Interstitial you should use the Load() method. This method must be invoked in the following way:

interstitial.Load();  

The result of this method will be received in the ** InterstitialListener** callbacks.

Showing the Interstitial

After the ad is loaded successfully, the method Show() must be used to display the ad.

Here’s is the sample of how to show interstitial on screen.

interstitial.Show(); 

Keep in mind, this method should be called always after receiving confirmation that the ad was loaded successfully. Otherwise, it’ll result in an error and nothing will be displayed.

Here is a complete code sample about how you can integrate the Interstitial.


<- Unity Plugin Banner Integration            -> Unity Plugin Rewarded Integration

Clone this wiki locally