Answer the question
In order to leave comments, you need to log in
What's wrong with admob?
In Unity, my code works, but on the phone, ads are not shown at all.
I have AdPlacement by AdMob installed (but I only use AdMob)
using UnityEngine;using GoogleMobileAds.Api;
public class GoogleMobileAdsDemoScript : MonoBehaviour
{
private InterstitialAd interstitial;
void Start()
{
MobileAds.Initialize(initStatus => { });
RequestInterstitial();
if (this.interstitial.IsLoaded())
{
this.interstitial.Show();
}
}
private void RequestInterstitial()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3940256099942544/1033173712";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/4411468910";
#else
string adUnitId = "unexpected_platform";
#endif
if (interstitial !=null)
{
interstitial.Destroy();
}
this.interstitial = new InterstitialAd(adUnitId);
AdRequest request = new AdRequest.Builder().Build();
this.interstitial.LoadAd(request);
}
}
Answer the question
In order to leave comments, you need to log in
I had such an error, most likely the ad has not yet had time to load. Both methods are called in Start, if possible, make the display on the button, and load it in Start () and in the Event (in my opinion it is called OnAdClosed, is in the documentation).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question