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

Fullscreen ads

fan-c-yu edited this page Mar 5, 2021 · 5 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.


Implementation procedure

  1. Get an instance of NendAdFullBoard with NewFullBoardAd method of NendAdFullBoard.
  2. Optionally register the call back of the event you want to handle.
    The events are as follows.
    public event NendAdFullBoardLoaded AdLoaded;
    public event NendAdFullBoardFailedToLoad AdFailedToLoad;
    public event NendAdFullBoardShown AdShown;
    public event NendAdFullBoardClick AdClicked;
    public event NendAdFullBoardDismiss AdDismissed;
  3. Load the ad with Load method of NendAdFullBoard.
    Error code at load failure is as follows.
    public enum FullBoardAdErrorType : int {
        FailedAdRequest, // Ad request failed
        InvalidAdSpaces, // Unavailable ad spaces.
        FailedDownloadImage // Failed to download ad image.
    }
  4. Display the ad with Show method of NendAdFullBoard.
    Note: When you close the fullscreen ads, the ad is not automatically reloaded. When updating the advertisement contents, you need to execute the loading process again.

Implementation sample

using UnityEngine;
using NendUnityPlugin.AD.FullBoard;

public class FullBoardObject : MonoBehaviour
{
    private NendAdFullBoard m_fullBoardAd;

    // Use this for initialization
    void Start ()
    {
        m_fullBoardAd = NendAdFullBoard.NewFullBoardAd (spotId, "apiKey");

        m_fullBoardAd.AdLoaded += (NendAdFullBoard instance) => {
            // Success
        };
        m_fullBoardAd.AdFailedToLoad += (NendAdFullBoard instance, NendAdFullBoard.FullBoardAdErrorType type) => {
            // Failure
        };
        m_fullBoardAd.AdShown += (NendAdFullBoard instance) => {
            // Display
        };
        m_fullBoardAd.AdClicked += (NendAdFullBoard instance) => {
            // Click
        };
        m_fullBoardAd.AdDismissed += (NendAdFullBoard instance) => {
            // Dismiss
        };
    }

    public void Load ()
    {
        // Load the ad
        m_fullBoardAd.Load ();
    }

    public void Show ()
    {
        // Display the ad
        m_fullBoardAd.Show ();
    }
}

About background color outside Safe Area

You can change the background color outside iPhoneX Safe Area more affinitive to your app looking & feeling.

m_fullBoardAd.AdLoaded += (NendAdFullBoard instance) => {
    // Success
    instance.IOSBackgroundColor = Color.white;
};

For more information, please check iOS wiki "About background color outside Safe Area".

Clone this wiki locally