[SOLVED][ADMOB] is absolete use interstitialeAd.Load()

NOTE : This exist in GoogleMobileAds-v7.4.0.unitypackage or above

Google Mobile Ads Unity Plugin
Changes 2023

There are ways to call ads that were changed in 2023
Some operations have been cancelled
also changed (adRequest)

interstitialAd = new InterstitialAd(adUnitId); cancled
interstitialAd.LoadAd(CreateAdRequest()); cancled

PROBLEMS:

'InterstitialAd.InterstitialAd(string)' is absolete 'Use InterstitialAd.Load().'

more info about errors:
Not work admob on scene
warning+CS0618
plugin ads error 2023
adRequest not work
use InterstitialAd.Load()

SOLUTION:
1-Request

private InterstitialAd interstitial;
   public string adUnitId;

   private void RequestInterstitial()
   {
       adUnitId = "ca-app-pub-3940256099942544/1033173712"; // test id

       // Clean up interstitial before using it
       if (interstitial != null)
       {
           interstitial.Destroy();
       }

       AdRequest request = new AdRequest.Builder().Build();
       InterstitialAd.Load(adUnitId, request, (InterstitialAd ad, LoadAdError loadAdError) =>
       {
           if (loadAdError != null)
           {
               return;
           }
           else
           if (ad == null)
           {
               return;
           }
           Debug.Log("Interstitial ad loaded");
           interstitial = ad;

       });
   }

2- Show

public void ShowInterstitialAd()  // Show
   {
       if (interstitial != null && interstitial.CanShowAd())
       {
           interstitial.Show();
       }
   }

Cheak if user close ad
Example:

private InterstitialAd interstitial;
    public string adUnitId;

    private void RequestInterstitial()
    {
        adUnitId = "ca-app-pub-3940256099942544/1033173712"; // test id

        // Clean up interstitial before using it
        if (interstitial != null)
        {
            interstitial.Destroy();
        }

        AdRequest request = new AdRequest.Builder().Build();
        InterstitialAd.Load(adUnitId, request, (InterstitialAd ad, LoadAdError loadAdError) =>
        {
            if (loadAdError != null)
            {
                return;
            }
            else
            if (ad == null)
            {
                return;
            }
            Debug.Log("Interstitial ad loaded");
            interstitial = ad;

            ad.OnAdFullScreenContentClosed += HandleOnAdFullScreenContentClosed;   //  >>>> HERE <<<<

        });

    }
    public void HandleOnAdFullScreenContentClosed()
    {
        Debug.Log("Interstitial ad Closed");
    }

sample Project from google : https://github.com/googleads/googleads-mobile-unity/tree/main/samples
moro info :https://github.com/googleads/googleads-mobile-unity/releases/tag/v7.4.0

3 Likes

Thank you brother. How to find this solution for rewarded ads ?

[quote=“mamafielsar3456”, post:2, topic: 907004]
Thank you brother. How to find this solution for rewarded ads ?
[/quote]
by webside > Github