我想在特定时间显示插页式广告。我手头加载广告然后再显示。如果Ad无法加载,我会使用计时器从didFailToRecieveAd再次加载它。但现在问题是 didFailToRecieveAd被称为multipleTimes 。
检查以下代码
- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.adUnitID = "XXX";
interstitial_.delegate = self;
[[GADRequest request] setTestDevices:[NSArray arrayWithObjects:@"75effd1496dd0f332738f26d48fcff01", nil]];
[self loadAd];
return self;
}
-(void) loadAdAgain{
[interstitial_ dealloc];
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.adUnitID = [[PreferenceHelper sharedHelper] getString:@"ad_unit_full_screen"];
interstitial_.delegate = self;
[[GADRequest request] setTestDevices:[NSArray arrayWithObjects:@"75effd1496dd0f332738f26d48fcff01", nil]];
loaded = NO;
[self loadAd];
}
-(void) loadAd{
[interstitial_ loadRequest:[GADRequest request]];
}
-(void) interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error{
[self trackEvent:@"ad_ios" action:@"Failed to load" label:[NSString stringWithFormat:@"ads_%d",adPresentedCount] value:[[PreferenceHelper sharedHelper] getInt:@"games"]];
[NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(loadAdAsync) userInfo:nil repeats:NO];
}
可能是什么原因?