Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Interstitial ads

fan-c-yu edited this page Mar 5, 2021 · 7 revisions

Preparation

If you have not created ad spaces or downloaded SDK, please refer to the link below.

SDK Implementation

If you have not imported Unity package into project, please follow the link below.


How to show interstitial ads

Procedure is as follows.

  1. Add NendAdInterstitial into “scene”
  2. Setting by Inspector(optional)
  3. Install codes
  4. Event handling(optional)
  5. Auto reload control(optional)

Add “Assets/NendAd/Scripts/AD/NendAdInterstitial.prefab” into Hierarchy by Drag&Drop. image

Interstitial ads uses IF of NendAdInterstitial class to control ad load, display etc.
NendAdInterstitial class instance can be acquired through “Getter” of Instance property.

  1. First, load interstitial ads. If there are muiple Oss for build, please set ad space information for each OS.
using NendUnityPlugin.AD;
...

#if UNITY_IOS
NendAdInterstitial.Instance.Load(ios_spotid, "ios_apikey");
#elif UNITY_ANDROID
NendAdInterstitial.Instance.Load(android_spotid, "android_apikey");
#else
...
#endif
  1. After ad load, you can display interstitial ads as you set.
using NendUnityPlugin.AD;
...

// Normal display
NendAdInterstitial.Instance.Show();

// Specify ad spaces and display them
NendAdInterstitial.Instance.Show(spotId);

You can receive event information such as ad-load, click etc. by adding delegation method to NendAdInterstitial Event handler.

using NendUnityPlugin.AD;
using NendUnityPlugin.Common;
...

NendAdInterstitial.Instance.AdLoaded += OnFinishLoadInterstitialAd;
NendAdInterstitial.Instance.AdShown += OnShowInterstitialAd;
NendAdInterstitial.Instance.AdClicked += OnClickInterstitialAd;
...

public void OnFinishLoadInterstitialAd (object sender, NendAdInterstitialLoadEventArgs args)
{
    UnityEngine.Debug.Log ("You received the event that ad load is completed.");
    switch (args.StatusCode) {
        ...
    }
}

public void OnClickInterstitialAd (object sender, NendAdInterstitialClickEventArgs args)
{
    UnityEngine.Debug.Log ("You received the event that ad is clicked.");
    switch (args.ClickType) {
        ...
    }
}

public void OnShowInterstitialAd (object sender, NendAdInterstitialShowEventArgs args)
{
    UnityEngine.Debug.Log ("You received the event that ad is displayed.");
    switch (args.ShowResult) {
        ...
    }
}

You can control if you reload ads automatically after interstitial ads are closed by changing IsAutoReloadEnabled property of NendAdInterstitial. Default setting is true.

using NendUnityPlugin.AD;
...

// Sample code to stop realoading ads.
NendAdInterstitial.Instance.IsAutoReloadEnabled = false;

Verification

Clone this wiki locally