- Home /
Unity Ads (Editor Integration) Not working only on iOS
Hi all,
Previously, I've had ads working on iPhone. I haven't changed the code, but for some reason I'm getting this error. This has apparently been an issue in 5.1, but was addressed and resolved by the Unity team in 5.1.1.
The exact same code is working just fine for Android and in-editor.
2016-08-10 17:52:11.800 dim[298:18160] Unity Ads is ready to show ads
2016-08-10 17:52:11.803 dim[298:18160] Launching ad from video, options: {
allowClientOverrides = (
noOfferScreen,
openAnimated,
muteVideoSounds,
useDeviceOrientationForVideo
);
allowSkipVideoInSeconds = 5;
allowVideoSkipInSeconds = 5;
default = 1;
defaultRewardItem = {
key = default;
name = "Default reward item";
picture = "https://static.applifier.com/unityads/unityicon_62.png";
};
deleted = 0;
disableBackButtonForSeconds = 30;
enabled = 1;
id = video;
incentivised = 0;
muteVideoSounds = 0;
name = Video;
noOfferScreen = 1;
openAnimated = 0;
rewardItems = (
{
key = default;
name = "Default reward item";
picture = "https://static.applifier.com/unityads/unityicon_62.png";
}
);
useDeviceOrientationForVideo = 0;
}
2016-08-10 17:52:11.809 dim[298:18160] Warning: Attempt to present <UnityAdsMainViewController: 0x128271110> on <UnityDefaultViewController: 0x126ee24d0> whose view is not in the window hierarchy!
Still having this issue. I tried downloading and implementing Unity Ads 2.0 (Beta) - but no luck.
Answer by Addyarb · Aug 11, 2016 at 11:25 PM
This is caused by trying to directly manipulate (via code) the screen orientation on iOS devices only.
As of v5.3.5f1, the use of this class anywhere in your project, even if it's a different scene, will break Unity Ads on iOS devices.[1]
But what is the solution if I need to manipulate screen orientation via code? Use another class or just "never use it even if you need to"?
Actually the solution is to use the Screen.autoRotate settings to dynamically constrain the orientation of the screen. The idea, I suppose, is that you're not setting the rotation, but rather not letting further rotations occur.