Chartboost成功展示了广告,但仍然“无法加载非页内广告,未找到广告!”

时间:2014-08-26 07:38:55

标签: admob chartboost

applicationDidBecomeActive中,如果调用了didFailToLoadInterstitial,我会弹出admob插页式广告。但chartboost成功展示了广告,仍然会调用didFailToLoadInterstitial,因此两个插页式广告都会弹出。

如何解决? 我怎么知道chartboost成功展示广告?然后我不需要弹出admob interstitial。

修改

- (void)didDismissInterstitial:(NSString *)location {

    NSLog(@"dismissed interstitial at location %@", location);

    [[Chartboost sharedChartboost] cacheInterstitial:location];

}

我必须在上面的代码中使用自动缓存,因为它可以减少加载广告的时间。

我需要展示chartboost广告,如果它无法显示,那么应用应该显示admob插页式广告。

[[Chartboost sharedChartboost] cacheInterstitial:location];[[Chartboost sharedChartboost] showInterstitial:CBLocationHomeScreen];函数如果加载错误,都会调用didFailToLoadInterstitial

他们可以调用不同的didFailToLoadInterstitial函数吗?因此,当chartboost showInterstitial加载错误时,我可以调用admob Interstitial。

有没有办法知道现在可以展示多少个chartboost广告?

1 个答案:

答案 0 :(得分:0)

@property (nonatomic, assign) BOOL donotShowAdmob;
@property (strong, nonatomic) NSTimer *myTimer;

- (void)applicationDidBecomeActive:(UIApplication *)application {

    // Begin a user session. Must not be dependent on user actions or any prior network requests.
    // Must be called every time your app becomes active.
    [Chartboost startWithAppId:@"537a2fe489b0bb64ac855ce2" appSignature:@"38cc6952604d5ab537deb627f2d91087f430df2b" delegate:self];

    if(![[AdManager inst] isRemoveAd])
    {
        [[Chartboost sharedChartboost] showInterstitial:CBLocationHomeScreen];
        [[Chartboost sharedChartboost] showInterstitial:CBLocationQuit];
    }
}

-(void) errorLoadAd
{
    if(!_donotShowAdmob)
    {
        MainViewController* cont=self.viewController;
        [cont showInterstitial ];
    }
}
- (BOOL)shouldDisplayInterstitial:(NSString *)location {
    _donotShowAdmob=TRUE;
    if (_myTimer!=nil) {
        [_myTimer invalidate];
        _myTimer = nil;
    }

    _myTimer = [NSTimer scheduledTimerWithTimeInterval: 3.0
      target: self
      selector:@selector(onTick:)
      userInfo: nil repeats:NO];

// Otherwise return YES to display the interstitial
    return YES;

}

-(void)onTick:(NSTimer*)timer
{
    _donotShowAdmob=FALSE;
    NSLog(@"Tick...");
}
- (void)didFailToLoadInterstitial:(NSString *)location withError:(CBLoadError)error {
    [self errorLoadAd];

    switch(error){
        case CBLoadErrorInternetUnavailable: {
            NSLog(@"Failed to load Interstitial, no Internet connection !");
        } break;
        case CBLoadErrorInternal: {
            NSLog(@"Failed to load Interstitial, internal error !");
        } break;
        case CBLoadErrorNetworkFailure: {
            NSLog(@"Failed to load Interstitial, network error !");
        } break;
        case CBLoadErrorWrongOrientation: {
            NSLog(@"Failed to load Interstitial, wrong orientation !");
        } break;
        case CBLoadErrorTooManyConnections: {
            NSLog(@"Failed to load Interstitial, too many connections !");
        } break;
        case CBLoadErrorFirstSessionInterstitialsDisabled: {
            NSLog(@"Failed to load Interstitial, first session !");
        } break;
        case CBLoadErrorNoAdFound : {
            NSLog(@"Failed to load Interstitial, no ad found !");
        } break;
        case CBLoadErrorSessionNotStarted : {
            NSLog(@"Failed to load Interstitial, session not started !");
        } break;
        default: {
            NSLog(@"Failed to load Interstitial, unknown error !");
        }
    }
}

我使用NSTimer解决它,在chartboost显示确定后的3秒内,不显示非正式插页式广告。但有时候,有两个广告显示......

修改hasCachedInterstitial

解决