Main functions

  • Display of fullscreen interstitial advertisement
  • Callback support from fullscreen interstitial advertisement
  • Support for each SDK mediation

System operating environment

  • Android
    • Android SDK 4.1 or later
  • iOS
    • iOS 9.0 or later
    • 64bit for iOS

Development environment

  • Unity 2019.2.12f1
  • JDK 1.8 or later
  • SDK build target 28

Plugin Installation Procedure

I will explain the procedure for installing Plugin to Unity.

  1. Import GNSAdSDK-UnityPlugin-Interstitial plugin to Unity project
  2. Register events for fullscreen interstitial advertisement using Plugin API
  3. Add discard processing
  4. Load fullscreen interstitial advertisement
  5. Display of fullscreen interstitial advertisement

1. Import GNSAdSDK-UnityPlugin-Interstitial plugin to Unity project

  1. Open the Unity project that incorporates the plugin.
  2. Refer to [https://github.com/googlesamples/unity-jar-resolver] (http://github.com/googlesamples/unity-jar-resolver) and introduce PlayServicesResolver.
  3. Select Assets -> Import Package -> Custom Package from the menu bar.
  4. Select the GNSAdSDK-UnityPlugin-Interstitial-2.0.0.unitypackage file in the folder.
  5. Make sure all files' checkboxes are checked and click Import.

2. Using the Plugin API, register events for fullscreen interstitialadvertisement

The code below is necessary to create a fullscreen interstitial advertisement and register an event. When registering an event, please complete the registration process before loading the ad.

using GNSAdSDK.Api;

...

private static bool isRegistedFullscreenInterstitialAdEventHandler = false;

private void RegistFullscreenInterstitialAdEventHandler ()
{
    if (!isRegistedFullscreenInterstitialAdEventHandler) {
        FullscreenInterstitialAd fullscreenInterstitialAd = FullscreenInterstitialAd.Instance;

        fullscreenInterstitialAd.OnAdLoaded + = (object sender, System.EventArgs args) => {
            / / Processing when loading fullscreen interstitialads is complete
        };
        fullscreenInterstitialAd.OnAdStarted + = (object sender, FullscreenInterstitialAdData args) => {
            // Processing when fullscreen interstitialadvertisement is played
            / / * For iOS only, an instance of FullscreenInterstitialAdData with all properties empty is passed to args.
        };
        fullscreenInterstitialAd.OnAdClosed + = (object sender, FullscreenInterstitialAdData args) => {
            // Processing when the fullscreen interstitialad is closed
            / / * For iOS only, an instance of FullscreenInterstitialAdData with all properties empty is passed to args.
        };
        fullscreenInterstitialAd.OnAdFailedToLoad + = (object sender, FullscreenInterstitialAdFailedData args) => {
            // Processing when loading fullscreen interstitial advertisement fails
        };
    }
    isRegistedFullscreenInterstitialAdEventHandler = true;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  • The FullscreenInterstitialAd instance is a singleton object for manipulating fullscreen interstitialadvertisements.
  • Since FullscreenInterstitialAd instance is a singleton object, we recommend that you register events only once to avoid event duplication.

FullscreenInterstitialAdFailedData possesses the following properties.

public class FullscreenInterstitialAdFailedData: EventArgs
{
    // Ad network name
    // * For iOS, it is always null.
    public string AdnetworkName {get; set;}
    // code
    public int Code {get; set;}
    // Message
    public string Message {get; set;}
}
1
2
3
4
5
6
7
8
9
10
11

3. Add destruction processing

For Android In order to perform discard processing at OnDestroy, please set the Application.Quit callback as follows.

  • It is not mandatory when creating only iOS.
using GNSAdSDK.Api;

...

void OnApplicationQuit() {
    FullscreenInterstitialAd.Instance.DisposeAd();
}
1
2
3
4
5
6
7
8

4. Load fullscreen interstitialadvertisement

Below is the code necessary for loading fullscreen interstitialads.

using GNSAdSDK.Api;

...

private void LoadFullscreenInterstitialAd ()
{
    #if UNITY_ANDROID
        string zoneId = "Please insert zoneId here";
    #elif UNITY_IPHONE
        string zoneId = "Please insert zoneId here";
    # else
        string zoneId = "dummy";
    # endif

    FullscreenInterstitialAd fullscreenInterstitialAd = FullscreenInterstitialAd.Instance;
    fullscreenInterstitialAd.LoadAd (zoneId);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  • The FullscreenInterstitialAd instance is a singleton object for manipulating fullscreen interstitial advertisements.
  • Loading may take more than a few seconds, please load ads early.
  • If you want to show another ad after the completion of playback of one ad, you need to load again.

5. Display fullscreen interstitialadvertisement

The code below is necessary for displaying fullscreen interstitial advertisement. After loading the movie, you can call ShowAd ().

using GNSAdSDK.Api;

...

private void ShowFullscreenInterstitialAd()
{
   FullscreenInterstitialAd fullscreenInterstitialAd = FullscreenInterstitialAd.Instance;

    // Check if the animation can be displayed
    if (fullscreenInterstitialAd.IsLoaded ()) {
        // Display advertisement
        fullscreenInterstitialAd.ShowAd ();
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

6. About pre-call advertisement

Points to note when you want to load the next ad before showing advertisement

Implement LoadAd (zoneId); into the ad close event (OnAdClosed).

Last Updated: 7/21/2020, 4:39:55 PM