I’ve made a simple endless runner game, and used Unity ads in it. On testing in the editor, the ads work showing the unity ad images, but when i build the apk and install on android, no ads work. Neither the banner nor the interstitial. Please help.
This is the script I’m using to initialize the ads.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
public class AdScript : MonoBehaviour
{
string gameId = “*******”;
bool testMode = true;
public string placementId = “bannerad”;
public string interstid = “LevelComplete”;
private static AdScript inst = null;
public static AdScript Inst
{
get { return inst; }
}
void Awake()
{
if (inst != null && inst != this)
{
Destroy(this.gameObject);
return;
}
else
{
inst = this;
}
DontDestroyOnLoad(this.gameObject);
}
void Start()
{
Advertisement.Initialize(gameId, testMode);
StartCoroutine(ShowBannerWhenInitialized());
Debug.Log(“Initialized ads”);
}
public void ShowInterstitialAd()
{
if (Advertisement.IsReady())
{
Advertisement.Show(interstid);
}
else
{
Debug.Log(“Interstitial ad not ready at the moment! Please try again later!”);
}
}
IEnumerator ShowBannerWhenInitialized()
{
while (!Advertisement.isInitialized)
{
yield return new WaitForSeconds(0.5f);
}
Advertisement.Banner.SetPosition(BannerPosition.TOP_LEFT);
Advertisement.Banner.Show(placementId);
}
}