Quick Start

This page helps you get the plugin running as fast as possible. For advanced functionalities, we recommend checking the Complete API.

The same code works for both Android and iOS platforms and all advertisers.

Initialize the plugin

The initialization should be made only once at the start of your app. After initialization, the ads start loading automatically in the background to be ready when you need them.

The initialization method will display the consent popup if required. No additional methods are needed.

Test.cs
public class Test : MonoBehaviour
{
    void Start()
    {
        Gley.MobileAds.API.Initialize(OnInitialized);
    }

    private void OnInitialized()
    {
        //Show ads only after this method is called
        //This callback is not mandatory if you do not want to show banners as soon as your app starts.
    }
}

Show banner ad

This example uses a public method to display a banner by specifying the banner position on the screen and the type of banner to be displayed.

Test.cs
public void ShowBanner()
{
    Gley.MobileAds.API.ShowBanner(BannerPosition.Bottom, BannerType.Banner);
}

Hide banner ad

Hides a banner from the screen

Test.cs
public void HideBanner()
{
    Gley.MobileAds.API.HideBanner();
}

Show interstitial ad

Displays a full-screen interstitial ad. After an ad is closed, another one is automatically loaded.

Test.cs
public void ShowInterstitial()
{
    Gley.MobileAds.API.ShowInterstitial();
}

Show rewarded video ad

Displays a rewarded video and rewards the user for completely watching the video. After an ad is closed another one is automatically loaded.

The CompleteMethod callback is automatically called and if the complete variable is true, it means that the user watched the video until the end and the reward should be granted.

Test.cs
int coins = 0;

public void ShowRewardedVideo()
{
    Gley.MobileAds.API.ShowRewardedVideo(CompleteMethod);
}

private void CompleteMethod(bool completed)
{
    if (completed)
    {
        coins += 100;
    }
}

This concludes the Quick Start. Check the Complete API for advanced functionalities.

For a complete example check the scene included in the package:

Assets/Gley/MobileAds/Example/Scenes/MobileAdsExample.unity

Last updated