Log Error:
<Notice>: AdColony [***ERROR ***] : AdColony has ads, but could not display them. AdColony was unable to find the currently visible UIViewController for your app. Please ensure that your key UIWindow has a rootViewController.
UIWindow for presenting ad:
Each View in an application is enclosed by a UIWindow. Some applications can have multiple windows associated but each window is independent of one other and have different UIViewControllers associated with them.
The SDK attempts to present the ad on the topmost ViewController of the navigation stack of the UIWindow. In case the application has multiple UIWindows, the first UIWindow from the array of windows is selected.
The events are passed to the corresponding UIWindows associated with the UIViewControllers where they occur, but in cases the events do not have a relevant coordinate associated with them, they are sent to the key Window. Thus, it’s a good practice to make UIWindow being presented as the key Window using makeKey() to ensure that no touch events are lost . Only one UIWindow can be the key window at a time. The property isKeyWindow returns a bool value to verify if the window is a keyWindow or not.
When presenting ads, the SDK does not check for the keyWindow, but picks the first window from the array of UIWindows. Since, the keyWindow is responsible for hearing all the touch events that do not have any coordinates associated with them, a keyboard or any other UIElement pending user action that is present on screen, can become the keyWindow. For instance, if a textfield is clicked, bringing the keyboard on screen, then the keyboard will be returned as the keyWindow.
Hence, to make sure that the ads are presented on a ViewController, it is imperative that the UIWindow presenting the ads is not just a UIElement like keyboard, but a window that has ViewControllers associated with it. Thus, the best practice is to ensure that the UIViewController on which the ad should be shown is being presented by the UIWindow, which is the first windows in windows array.