Chartboost interstitial : "not in the window hierarchy!" warning

286 Views Asked by At

On iOS, when I displayed a Chartboost interstitial, I have "sometimes" (yes.. not all the time) the following message when I clicked on the interstitial :

Warning: Attempt to present on whose view is not in the window hierarchy!

I just call Chartboost like that:

[[Chartboost sharedChartboost] showInterstitial:CBLocationGameOver];

And at startup I cached this interstitial:

[[Chartboost sharedChartboost] cacheInterstitial:CBLocationGameOver];

I really don't understand this issue. And it's not all the time. I can't explain and understand why sometimes it works (When I touch the interstitial I have the App Store opened) and why sometimes the interstitial just disappeared and nothing happens.

I tried since 3 or 4 months to ask Chartboost about this but I never had a good answer.

1

There are 1 best solutions below

0
On BEST ANSWER

You should specify the view where Chartboost should show the ad. For doing that there is a method call:

[[Chartboost sharedChartboost] setRootView:YOUR_VIEW];

With that sentence you can make Chartboost show ads in an specific view.

You should call this one just before calling "showInterstitial"

UPDATE:

With the version 5.0 of the SDK they have changed this method. Now you should use

[Chartboost showInterstitial:{view Controller} location:CBLocationHomeScreen];

But with some versions this method doesn't appear in the Chartboost.h file. If this is your case, simply add this line on this file:

+ (void)showInterstitial:(UIViewController *)viewController
            location:(CBLocation)location;