游戏结束时的非页内广告

时间:2014-05-29 13:41:50

标签: ios admob sprite-kit interstitial

我使用AdMob横幅开发了一款IOS Sprite Kit游戏。我想添加插页式广告,但不会在游戏开始时添加。我有一个GameOverScene,其间应该显示插页式广告。不是在游戏开始时,而是每次游戏结束时(加载GameOverScene时)

这是我的代码: ViewController.h

#import <UIKit/UIKit.h>
#import <SpriteKit/SpriteKit.h>
#import "GADBannerView.h"
#import "GADInterstitial.h"

@class GADBannerView, GADRequest;

@interface ViewController : UIViewController<GADBannerViewDelegate>
{
    GADBannerView *bannerView_;
    GADInterstitial *interstitial_;
}

@property (nonatomic, strong)GADBannerView *bannerView;
-(GADRequest *)createRequest;
-(void)createInterstitial;
@end

ViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];

    //Other code
    Interstitial
    interstitial_ = [[GADInterstitial alloc] init];
    interstitial_.delegate = self;
    interstitial_.adUnitID = MyInterstitialUnitID;
    [interstitial_ loadRequest:[GADRequest request]];

    //Other code

}

1 个答案:

答案 0 :(得分:1)

检查 googleads sample for interstitals 您需要添加interstitialDidReceiveAd方法来设置收到广告的标记,然后在游戏结束时调用此[interstitial_ presentFromRootViewController:self];,如果您发现该标记为真。
编辑: -
另外,要重新加载广告,您可以添加interstitialDidDismissScreen方法来调用[interstitial_ loadRequest:[GADRequest request]];