如何在ios应用程序中显示插页式广告?

时间:2017-07-10 11:31:48

标签: ios interstitial

每当我打开类别时,插页式广告显示我想让它显示一次

代码

//----------Interstitial Initialization-------------//
-(void)createAndLoadInterstitial
{
    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

    _interstitial = [[GADInterstitial alloc] initWithAdUnitID:appDelegate.InterstitialAdUnitID];
    _interstitial.delegate = self;
    [_interstitial loadRequest:[GADRequest request]];
}
- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial
{
    [_interstitial presentFromRootViewController:self];
}
- (void)interstitial:(GADInterstitial *)interstitial didFailToReceiveAdWithError:(GADRequestError *)error
{
    NSLog(@"interstitialDidFailToReceiveAdWithError: %@", [error localizedDescription]);
}
- (void)interstitialDidDismissScreen:(GADInterstitial *)interstitial
{
    NSLog(@"interstitialDidDismissScreen");
}

1 个答案:

答案 0 :(得分:0)

试试这个

static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
//call your method here
     [self createAndLoadInterstitial];
    });