0
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ Maybe try to avoid running more code after Show, and rather use the callback function from the Show() var options = new ShowOptions { resultCallback = HandleShowResult }; Advertisement.Show(RewardedZoneId, options); \$\endgroup\$ Commented Nov 22, 2016 at 14:00
  • \$\begingroup\$ @sphair Thats how I ultimately solved it but I just want to know why it has a different behavior on iOS and Android :D \$\endgroup\$ Commented Nov 22, 2016 at 14:23

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.