Test Ad plays in editor but won't play on iOS device

Hello!

I am in the process of adding UnityAds to our game but as the subject suggests am having problems viewing the ads on device. I get this warning in XCode when I try to play the video:

Warning: Attempt to present <UnityAdsMainViewController: 0x1a350880> on <UnityDefaultViewController: 0x17ee2d30> whose view is not in the window hierarchy!

This happens after I have checked that a video is available (which it is) and then attempted to play it. My code looks like this:

// At startup

Advertisement.Initialize(unityAdsID);

// Later when someone clicks the watch video button

if(Advertisement.isReady())
{
Advertisement.Show(null, newShowOptions(){pause = true, resultCallback = UnityAdWatched});
}

…exactly like the docs say to do. Note that the callback (UnityAdWatched) never gets hit.

Any ideas? I’m stumped.

I’m using Unity 4.6.1 XCode 6.1.1 and an iPhone4S

Thanks in advance!

Hi, I am having exactly the same warning & setup as you on iOS. For Android and in the Editor everything is working fine.
Really hope someone can help…

We have reproduced the problem at the Unity Ads SDK team. We will let you know when we have a fix ready.

1 Like

Ah ha, I’m having the exact same problem so will keep an eye on this post for the resolution.

the same problem to me, don’t know what problem~

We have uploaded a new version 1.1.1 to Asset Store that fixes this issue. It will be available once asset store team processes the submission queue.

Unfortunately we have also discovered another iOS issue with Unity 5. If you are using Unity 5 and iOS, AdSupport.framework doesn’t get automatically linked into the project. To fix this manually, go to Unity-iPhone targets Build Phases tab and add AdSupport.framework to the Link Binary With Libraries section. We are working to automate this.

jannen
Can you provide a link on 1.1.1 version?
There is only 1.1.0 currently on Asset Store.

Unfortunately asset store update appears to take a bit longer than what I expected. You can do the same fix manually by updating Assets/Plugins/iOS/UnityAdsUnityWrapper.mm.

Find the show method and add the following line on top of the line with return statement:

[[UnityAds sharedInstance] setViewController:UnityGetGLViewController()];

This will be line 140 and the return statement of show method will be on line 141.

Hello Jannen,

did you use projmods to automate adding AdSupport.framework? It seems it was broken in Unity 5. Was working fine before we upgraded.