Chartboost with Swift - Interstitial: prefetch if NOT complete. wait… but no ad?

旧街凉风 提交于 2019-12-24 06:38:04

问题


I am trying to integrate Chartboost ads in Swift into my project and have followed the tutorial verbatim:

https://answers.chartboost.com/hc/en-us/articles/205853276

Everything is imported and in App delegate I have:

Chartboost.startWithAppId(//stuff)
        Chartboost.setShouldRequestInterstitialsInFirstSession(false)
        Chartboost.cacheMoreApps(CBLocationHomeScreen)

//Chartboost

class func showChartboostAds()
{
    Chartboost.showInterstitial(CBLocationHomeScreen);
}

func didFailToLoadInterstitial(location :String!, withError error: CBLoadError)
{

}

func didDismissInterstitial(location :String! )
{
    if(location == CBLocationHomeScreen)
    {
        Chartboost.cacheInterstitial(CBLocationMainMenu)
    }
    else if(location == CBLocationMainMenu)
    {
        Chartboost.cacheInterstitial(CBLocationGameOver)
    }
    else if(location == CBLocationGameOver)
    {
        Chartboost.cacheInterstitial(CBLocationLevelComplete)
    }
    else if(location == CBLocationLevelComplete)
    {
        Chartboost.cacheInterstitial(CBLocationHomeScreen)
    }
}

Then in my main view controlleR:

AppDelegate.showChartboostAds()

I have my app in test mode in the dashboard and am running on a real device but I just get Interstitial: prefetch if NOT complete. wait... in the console.

Why won't it show any ads?


回答1:


I think you're trying to show the AD to quickly. Try delaying the AD, that solved it for me.




回答2:


Just an aside, the reason this solution works is because of the prefetch method. It seems when you call the ad the Chartboost prefetch isn't completing on time, which is causing the show call to fail.

Chartboost does have a delegate method that will give you the all-clear when prefetch completes, that may be worth a look: - (void)didPrefetchVideos;

Here's a link to the rest of the page.

Hope this helps.



来源:https://stackoverflow.com/questions/38919940/chartboost-with-swift-interstitial-prefetch-if-not-complete-wait-but-no-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!