Warning: Attempt to present <UnityAdsMainViewController: 0x1a728000>

I’m trying to implement Unity Ads for iOS. When I click to show ad I get this error in the console:

Warning: Attempt to present <UnityAdsMainViewController: 0x1a728000> on <UnityLandscapeRightOnlyViewController: 0x1a4c72c0> whose view is not in the window hierarchy!

Anyone has come across this error before and knows how to deal with it?

Thanks in advance.

In case someone comes across the same issue, it was caused by our code messing with the allowed orientations.

e.x.
Screen.orientation = ScreenOrientation.LandscapeRight;

We removed this restriction and the error went away.

1 Like

Interesting, ran into same issue. I was trying to limit auto rotation to LandscapeLeft and LandscapeRight only. Works perfectly fine on Android… iOS pukes.

Hi,
I tried changing the rotation settings on my game (is in portrait mode), the error stays and Unity ads aren’t shown:

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

Would be great if someone can help!

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.

1 Like

@jannen Does Asset Store Team process the submission queue during the weekends?

@jannen
I also want to know when I can get 1.1.1 package. How long does it take usually?

Same here! Wish I knew that the package was broken before updating.

Unfortunately the asset store update seems to be taking longer than what I expected. Here is the same fix that you can put in your project manually. The relevant file is 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.

@jannen Thank you for sharing the fix.

@jannen Thanks for providing the fix. I followed the instructions but its throwing an error:

…/UnityAdsUnityWrapper.mm:139:80: Non-ASCII characters are not allowed outside of literals and identifiers

Sometimes you can get non-ASCII characters when copy&pasting from browser to some text editor. It appears that Xcode complains about non-ASCII character at the end of line. It’s obviously difficult to say what kind of whitespace character there is but I would try to delete that somehow. If that doesn’t work with your usual text editor, maybe you can try a different text editor that would work better with whitespace characters.

no probs, thanks for the reply :slight_smile: Just saw v1.1.2 is up on the asset store now and that’s probably got all this fixed up!

Yes, the new release is now available and it fixes this issue.

I got the same problem now with Unity 5.2.1f1 Personal Edition.
I set the following:

Screen.orientation=ScreenOrientation.AutoRotation;
Screen.autorotateToPortrait=false;
Screen.autorotateToPortraitUpsideDown=false;
Screen.autorotateToLandscapeLeft=true;
Screen.autorotateToLandscapeRight=true;

Any ideas?

[EDIT]
Okay found it. I do the settings in the Player Settings and:

  • Log into the Unity Ads Admin
  • Select your game profile
  • Select the Monetization Settings tab
  • Select the Show Advanced Settings button
  • Select the Settings button for the zone you are using
  • Check the box under the Options section to enable