1

applicationDidBecomeActive,如果didFailToLoadInterstitial被调用,我会弹出 admob interstitial。但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];and [[Chartboost sharedChartboost] showInterstitial:CBLocationHomeScreen];函数都会调用。didFailToLoadInterstitial

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

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

4

1 回答 1

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 显示 ok 后 3 秒内,不显示 admob Interstitial。但有时,两个广告显示...

编辑: 解决者hasCachedInterstitial

于 2014-08-27T16:52:32.350 回答