- Home /
Question by
mohamadredamahrir444 · May 23, 2021 at 10:11 AM ·
androidunity 2dadmob
Google Admob doesnot Show When Unity App are build But the ads show Up when testing in the editor
public class AdmobManager : MonoBehaviour
{
public static AdmobManager Instance;
private InterstitialAd interstitial;
private string InterAdId;
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(this);
}
else if (Instance != this)
{
Destroy(this);
}
}
void Start()
{
InterAdId="adID" ;
MobileAds.Initialize(initStatus => { });
}
public void ShowAdd(int ratio)
{
RequestInterstitial();
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
private void RequestInterstitial()
{
interstitial = new InterstitialAd(InterAdId);
AdRequest request = new AdRequest.Builder().Build();
interstitial.LoadAd(request);
}
public void OnApplicationQuit()
{
if(interstitial!=null)
{
interstitial.Destroy();
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613034058im_/https://answers.unity.com/themes/thub/images/avi.jpg)