-EDIT- Can it be because of GPGS(Google Play Game Services)???
I have imported the Admob Unity SDK and configured it successfully with Test ads.
Everything works fine with test ads, but when I put my real ads strings even if I use AddTestDevice(SystemInfo.deviceUniqueIdentifier)
nothing happens.
I made another project to test the same real ads and the ads are shown ok.
So the problem is: real ads are shown fine in other projects but in the main project nothing happens, even if test ads work correctly.
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds;
using GoogleMobileAds.Api;
using System;
public class AdManager : MonoBehaviour
{
private RewardedAd rewardedAd;
private BannerView bannerView;
public InterstitialAd interstitial;
private void RequestInterstitial()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-2993038425431208/1298871084";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/4411468910";
#else
string adUnitId = "unexpected_platform";
#endif
this.interstitial = new InterstitialAd(adUnitId);
AdRequest request = new AdRequest.Builder().AddTestDevice(SystemInfo.deviceUniqueIdentifier).Build();
this.interstitial.LoadAd(request);
}
string appId;
public void Start()
{
#if UNITY_ANDROID
appId = "ca-app-pub-2993038425431208~5325638202";
#elif UNITY_IPHONE
appId = "ca-app-pub-3940256099942544~1458002511";
#else
appId = "unexpected_platform";
#endif
//AdRequest.Builder.addbcx("33BE2250B43518CCDA7DE426D04EE231");
MobileAds.Initialize(appId);
this.RequestBanner();
this.RequestInterstitial();
this.LoadReward();
}
private void LoadReward()
{
string adUnitId;
#if UNITY_ANDROID
adUnitId = "ca-app-pub-2993038425431208/2201384054";
#elif UNITY_IPHONE
adUnitId = "ca-app-pub-3940256099942544/1712485313";
#else
adUnitId = "unexpected_platform";
#endif
this.rewardedAd = new RewardedAd(adUnitId);
this.rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;
this.rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;
this.rewardedAd.OnAdOpening += HandleRewardedAdOpening;
this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;
this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
this.rewardedAd.OnAdClosed += HandleRewardedAdClosed;
AdRequest request = new AdRequest.Builder().AddTestDevice(SystemInfo.deviceUniqueIdentifier).Build();
this.rewardedAd.LoadAd(request);
}
public void HandleRewardedAdLoaded(object sender, EventArgs args)
{
MonoBehaviour.print("HandleRewardedAdLoaded event received");
}
public void HandleRewardedAdFailedToLoad(object sender, AdErrorEventArgs args)
{
MonoBehaviour.print(
"HandleRewardedAdFailedToLoad event received with message: "
+ args.Message);
}
public void HandleRewardedAdOpening(object sender, EventArgs args)
{
MonoBehaviour.print("HandleRewardedAdOpening event received");
}
public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args)
{
MonoBehaviour.print(
"HandleRewardedAdFailedToShow event received with message: "
+ args.Message);
}
public void HandleRewardedAdClosed(object sender, EventArgs args)
{
AdRequest request = new AdRequest.Builder().Build();
this.rewardedAd.LoadAd(request);
}
public void HandleUserEarnedReward(object sender, Reward args)
{
//Assets.SaveLoad.CloudManager.Instance.AddDiamonds(20);
}
public void showIntestitial()
{
if (this.interstitial.IsLoaded())
{
this.interstitial.Show();
this.RequestInterstitial();
}
}
public void ShowReward()
{
if (this.rewardedAd.IsLoaded())
{
this.rewardedAd.Show();
this.LoadReward();
}
}
public bool bottom;
private void RequestBanner()
{
if (!bottom)
{
return;
}
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-2993038425431208/8049796478";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/2934735716";
#else
string adUnitId = "unexpected_platform";
#endif
this.bannerView = new BannerView(adUnitId, new AdSize(AdSize.FullWidth, 50), AdPosition.Top);
AdRequest request = new AdRequest.Builder().AddTestDevice(SystemInfo.deviceUniqueIdentifier).Build();
this.bannerView.LoadAd(request);
this.bannerView.Show();
}
}