Unity Banner ads not show real ads in devices.
Hi,
Unity Banner ads only work in Editor, and does not deliver real ads in devices with android system. Is there an issue with the banner ads? Or there are simply no real banner ads to display yet?
Script: using System.Collections; using System.Collections.Generic; using UnityEngine.Advertisements; using UnityEngine.Monetization; using UnityEngine.UI; using UnityEngine;
public class AdManager : MonoBehaviour
{
string bannerPlacement = "bannerAd";
string rewardPlacement = "rewardedVideo";
string videoPlacement = "video";
bool testMode = false;
public const string gameID = "xxxxxxx";
public Text Testy;
void Start()
{
startTime = Time.time;
Advertisement.Initialize(gameID, testMode);
if (Monetization.isSupported) {
Monetization.Initialize(gameID, testMode);
}
StartCoroutine(ShowBannerWhenReady());
}
public void ShowVideoAd() {
ShowAdPlacementContent ad = null;
ad = Monetization.GetPlacementContent(videoPlacement) as ShowAdPlacementContent;
if (ad != null) {
ad.Show();
}
}
public bool RewardAdIsReady() {
if (Monetization.IsReady(rewardPlacement)) {
return true;
}
else { return false; }
}
public void ShowRewardAd() {
ShowAdPlacementContent ad = null;
ad = Monetization.GetPlacementContent(rewardPlacement) as ShowAdPlacementContent;
if (ad != null) {
ad.Show(HandleShowResult);
}
}
void HandleShowResult(UnityEngine.Monetization.ShowResult result) {
if (result == UnityEngine.Monetization.ShowResult.Finished) {
//
}
}
IEnumerator ShowBannerWhenReady() {
while (!Advertisement.IsReady("bannerAd")) {
yield return new WaitForSeconds(0.5f);
}
Advertisement.Banner.Show(bannerPlacement);
}
public void HideBannerAd() {
Advertisement.Banner.Hide();
}
}
Comment
Your answer