1

ではapplicationDidBecomeActivedidFailToLoadInterstitialが呼び出された場合、admob インタースティシャルをポップアップします。しかしchartboost、広告は正常に表示され、引き続き が呼び出さdidFailToLoadInterstitialれるため、2 つのインタースティシャル広告の両方がポップアップします。

それを解決する方法は?chartboost が広告を正常に表示することを確認するにはどうすればよいですか? 次に、admob インタースティシャルをポップアップする必要はありません。

編集:

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

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

    [[Chartboost sharedChartboost] cacheInterstitial:location];

}

広告をすぐに読み込む時間を短縮できるため、上記のコードでは自動キャッシュを使用する必要があります。

chartboost 広告を表示する必要があります。表示できない場合、アプリは代わりに admob Interstitial 広告を表示する必要があります。

[[Chartboost sharedChartboost] cacheInterstitial:location];および [[Chartboost sharedChartboost] showInterstitial:CBLocationHomeScreen];関数は、ロード エラーが発生した場合に呼び出され didFailToLoadInterstitialます。

それらは異なるdidFailToLoadInterstitial関数を呼び出すことができますか? したがって、chartboost showInterstitial の読み込みエラーが発生したときに admob Interstitial を呼び出すことができます。

現在表示できるチャートブースト広告の数を知る方法はありますか?

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 を使用します。それでも時々、2 つの広告が表示されることがあります...

編集: によって解決hasCachedInterstitial

于 2014-08-27T16:52:32.350 に答える