So I have this code for showing an ad. It is supposed to pause the app while the ad is showing. It works on android but on iOS it doesn't even seem to be called, judging from the debug msgs shown in Xcode. Here is the code :
IEnumerator ShowAndWaitForAd()
{
if (Advertisement.IsReady())
{
Debug.Log("Add is ready");
ShowOptions options = new ShowOptions();
options.resultCallback = AdCallbackhandler;
Advertisement.Show();
}
else {
Debug.Log("Add is not ready");
SceneManager.LoadSceneAsync(2);
GameObject.Find("Canvas").transform.FindChild("Loading").gameObject.SetActive(true);
Time.timeScale = 1;
}
float currentTimeScale = Time.timeScale;
Time.timeScale = 0f;
Debug.Log ("From show Ad, current time scale is: " + Time.timeScale);
Debug.Log ("current status of advertisement is : " + Advertisement.isShowing);
while (Advertisement.isShowing) {
Debug.Log ("!!!!!!Ad is showing!!!!!!");
yield return null;
}
SceneManager.LoadSceneAsync(2);
GameObject.Find("Canvas").transform.FindChild("Loading").gameObject.SetActive(true);
Debug.Log ("Setting timescale to 1!!!!!");
Time.timeScale = currentTimeScale;
}
On android this starts loading the level only after the ad has finished or has been skipped. On iOS this load the level while the ad is showing. That means that the line while (Advertisement.isShowing)
is being skipped for some reason. Has anyone encountered this before ?
Edit the problem seems to be that Advertisement.isShowing
is always returning false even when the ad is showing.