Question by
aym_awadallah · Apr 19 at 10:05 AM ·
editoradmobgoogle play
how to make this code in google play closed test??
this code is perfectly working in unity editor but when I try it in google play closed test it does not work because there are no ad displayed so my bool to pause my player stay true and the player did not move
public class InterstitialAd : MonoBehaviour
{
public string androidAdUnitId;
public string iosAdUnitId;
IInterstitialAd interstitialAd;
async void Start()
{
// Initialize the package to access API
await UnityServices.InitializeAsync();
// Instantiate an interstitial ad object with platform
if (Application.platform == RuntimePlatform.Android)
{
interstitialAd = MediationService.Instance.CreateI
}
else if (Application.platform == RuntimePlatform.IPhon
{
interstitialAd = MediationService.Instance.CreateI
}
if UNITY_EDITOR
else
{
interstitialAd = MediationService.Instance.CreateI
}
endif
// Subscribe callback methods to load events:
interstitialAd.OnLoaded += AdLoaded;
interstitialAd.OnFailedLoad += AdFailedToLoad;
// Subscribe callback methods to show events:
interstitialAd.OnShowed += AdShown;
interstitialAd.OnFailedShow += AdFailedToShow;
interstitialAd.OnClosed += AdClosed;
interstitialAd.Load();
Debug.Log("try LoadAd");
}
private void AdClosed(object sender, EventArgs e)
{
Debug.Log("Ad has closed");
StartBTNBehaviour.pause = false; //this bool control the player movement false = player
//move
// Execute logic after an ad has been closed.
}
public void ShowAd()
{
// Ensure the ad has loaded, then show it.
Debug.Log("try ShowAd");
if (interstitialAd.AdState == AdState.Loaded)
{
interstitialAd.Show();
Debug.Log("ShowAd");
}
else
{
Debug.Log("Failed ShowAd");
StartBTNBehaviour.pause = false; //added to test
}
}
so my problem is no ads in google closed test which make my pause bool not changed
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613055422im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Admob Rewarded Video Help!! Please help me :( Still an issue :( 1 Answer
My game is'nt working when i update it on GooglePlay 0 Answers
Admob impressions are not counted 0 Answers
Problem with Admob + Google Play Services plugin 2 Answers
Admob crashes when game is downloaded from Google Play but not on debug 0 Answers