简体   繁体   English

admob非页内广告未显示在ios上?

[英]admob interstitial not displaying on ios?

its been weeks that i have been trying to display admob interstitial ads with no luck, i have managed to display normal banner ads but i dont know the right way to display interstitial, here is the code i tried (following admob guide) 数周以来,我一直在尝试显示admob插页式广告的运气不佳,我设法显示了普通横幅广告,但是我不知道显示插页式广告的正确方法,这是我尝试的代码(在admob指南之后)

in my mainViewcontroller.h 在我的mainViewcontroller.h中

@interface MainViewController : CDVViewController 

<GADBannerViewDelegate> {
    GADBannerView *adBanner_;
    GADInterstitial *interstitial_;

}

and on my mainViewController.m 在我的mainViewController.m上

@implementation MainViewController


@synthesize adBanner = adBanner_;

#pragma mark init/dealloc

// Implement viewDidLoad to do additional setup after loading the view,
// typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];


    interstitial_ = [[GADInterstitial alloc] init];
    interstitial_.adUnitID = @"XXXXXXXXXXXXXX";
    [interstitial_ loadRequest:[GADRequest request]];
    [interstitial_ presentFromRootViewController:self];



    // Initialize the banner at the bottom of the screen.
    [adBanner_ setFrame:CGRectMake(100,
                                     100,
                                     adBanner_.bounds.size.width,
                                     adBanner_.bounds.size.height)];

    // Use predefined GADAdSize constants to define the GADBannerView.
    self.adBanner = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner
                                                    ]
                     autorelease];

    // Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID
    // before compiling.
    self.adBanner.adUnitID = @"XXXXXXXXXXXXXXX";
    self.adBanner.delegate = self;
    [self.adBanner setRootViewController:self];
    [self.view addSubview:self.adBanner];
    self.adBanner.center =
    CGPointMake(self.view.center.x, self.adBanner.center.y);
    [self.adBanner loadRequest:[self createRequest]];



}

You need to wait until the ad loads successfully and only then present it in case of Interstitial ads. 您需要等待广告成功加载,然后才能在非页内广告中展示它。 Otherwise the ads wont show up. 否则,广告将不会显示。

To do this confirm to the GADInterstitialDelegate protocol and set your view controller as the delegate of interstitial_. 为此,请确认GADInterstitialDelegate协议,并将您的视图控制器设置为interstitial_的委托。

interstitial_.delegate = self;

Then implement interstitialDidReceiveAd as follows. 然后按以下方式实现interstitialDidReceiveAd。

- (void)interstitialDidReceiveAd:(DFPInterstitial *)ad
{
    [interstitial_ presentFromRootViewController:self];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM