Aller au contenu principal

Interstitial Ad

Integration

Step 1. Instantiate Interstitial Ad

You can instanstiate a Interstitial ad right after SDK finish it's initialization. You have to pass the platform specific interstitial placement id in InterstitialAd constructor.

_interstitialAd = new InterstitialAd("your_ad_placement");

Step 2. Register event listeners

InterstitialAd exposes the following events through it's lifecycle.

MethodsDefinition
OnInterstitialDidLoadedAd is successfully loaded and SDK is ready to display the ad.
OnInterstitialDidFailThe ad failed to load or display. An additional error parameter of type BlueStackError contains the reason of the failure.
OnInterstitialClickedUser has clicked the ad. Ad may open a link in browser.
OnInterstitialDidShownAd has appeared on the screen.
OnInterstitialDisappearThe ad has disappeared.

To register for interstitial ad events, add the following code after instantiating InterstitialAd.

    _interstitialAd.OnInterstitialDidLoaded += (sender, args) =>
{
};

_interstitialAd.OnInterstitialDidFail += (sender, args) =>
{
};

_interstitialAd.OnInterstitialClicked += (sender, args) =>
{
};

_interstitialAd.OnInterstitialDidShown += (sender, args) =>
{
};

_interstitialAd.OnInterstitialDisappear += (sender, args) =>
{
};

attention

Make sure you only register event listener once.

Step 3. Load Interstitial ad

InterstitialAd expose two Load medthods to load ad. One takes Preference instance others emtpy parameters.

  • Without Preference
_interstitialAd.Load();
  • With Preference

Preference _preference = new Preference();
Location myLocation = new Location(Location.NONE_PROVIDER)
{
Latitude = 35.757866,
Longitude = 10.810547
};
_preference.SetAge(25);
_preference.SetLanguage("en");
_preference.SetGender(Gender.Male);
_preference.SetKeyword("brand=myBrand;category=sport");
_preference.SetLocation(myLocation, 3);
_preference.SetContentUrl("https://madvertise.com/en/");

_interstitialAd.Load(_preference);

Note : The setLocation method takes the following parameters:

  • the Location instance.
  • the CONSENT_FLAG value (corresponds to a int : 0,1,2 or 3).
    • 0 = Not allow to send location.
    • 1 = When you managed location according to consent value.
    • 2 and 3 = Allow the SDK to managed location directly in accordance with the consent value use TCF v1 or TCF v2, see with the madvertise team it depends on your implementation.

Step 4. Display Interstitial ad

After loading the interstitial ad you can request it to be displayed.

info

Register to OnInterstitialDidLoaded to make sure the ad was successfully loaded before you call Show() method

_interstitialAd.Show();

Destroy interstitial ad

To properly manage resources, make sure to destroy the banner ad when it is no longer in use.

_interstitialAd.Destroy()