简体   繁体   English

如何在整个视图中显示iad或admob

[英]How to show iad or admob in the whole view

i did a game in IOS mobiles, and i add iAd and when it fails ad-mob will be shown. 我在IOS手机上做了一个游戏,我添加了iAd,当它失败时,将显示ad-mob。 in my game there is a function called GameOver Whenever the user loss this function will be called. 在我的游戏中,有一个名为GameOver的函数。每当用户丢失时,都会调用此函数。 Now what i want is how i can add advertisement in the whole view when the user loss the advertisement in the whole view will be shown. 现在,我想要的是当用户在整个视图中丢失广告时,如何在整个视图中添加广告。

As you can see in app-store, there are games when the user loss, a view popup and it contain an advertisement and a video. 如您在应用商店中所看到的,当用户迷失时,会有一些游戏,一个视图弹出窗口,其中包含广告和视频。 I tried to do it, but the only thing that I'm getting is a small banner for iAd. 我尝试这样做,但唯一得到的是iAd的小横幅。

Full screen is known as Interstitial ad. 全屏广告称为非页内广告。

For showing interstitial ad in Admob:- 对于在Admob中展示插页式广告:-

  1. Create an adUnitID from Admob , select Interstitial ad in ad type. Admob创建adUnitID,然后在广告类型中选择非页内广告。

     - (void)createAndLoadInterstitial { self.interstitial = [[GADInterstitial alloc] init]; self.interstitial.adUnitID = @"YOUR_AD_UNIT_ID"; self.interstitial.delegate = self; GADRequest *request = [GADRequest request]; request.testDevices = ARRAY_OF_TEST_DEVICE_ID; [self.interstitial loadRequest:request]; } 
  2. iAd currently provides full screen ad only for iPad. iAd当前仅为iPad提供全屏广告。 If you app is running in iPhone there is no any way to show full screen ad via iAd. 如果您的应用程序在iPhone中运行,则无法通过iAd显示全屏广告。

Apple's doc for full screen iAd Apple的全屏iAd文档

you can use this for full view 您可以使用它进行全视图

- (void)createAndLoadInterstitial
{
 self.interstitial = [[GADInterstitial alloc] init];
 self.interstitial.adUnitID = @"ca-xxx-xxx-xxxxxxxxxxxxxxxxxxxx";
 self.interstitial.delegate = self;

GADRequest *request = [GADRequest request];
request.testDevices = @[
@"xxxxxxxxxxxxxxxxxxxxxxx"  
];
[self.interstitial loadRequest:request];
}



#pragma mark GADInterstitialDelegate implementation

- (void)interstitial:(GADInterstitial *)interstitial
didFailToReceiveAdWithError:(GADRequestError *)error {
  NSLog(@"interstitialDidFailToReceiveAdWithError: %@", [error localizedDescription]);
    }

- (void)interstitialDidDismissScreen:(GADInterstitial *)interstitial{
 NSLog(@"interstitialDidDismissScreen");
 //do you work
}

and framework - GoogleMobileAds 和框架-GoogleMobileAds

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

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