一:前提條件
將 SDK 添加到Xcode項目部分。
二:將插頁式廣告添加到項目中
對於GADInterstitial,建議您採用以下的生命週期設置:在應用啓動時預加載它,並在它準備就緒後選擇合適的時機在應用中展現它。如下代碼段顯示瞭如何建立GADInterstitial媒體資源、初始化該資源並隨廣告加載它。
#import "GADInterstitial.h"
@interface ViewController ()
@property(nonatomic, strong) GADInterstitial *interstitial;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.adUnitID = @"ca-app-pub-3940256099942544/4411468910";
GADRequest *request = [GADRequest request];
// Requests test ads on simulators.
request.testDevices = @[ GAD_SIMULATOR_ID ];
[self.interstitial loadRequest:request];
}
當您能夠展現插頁式廣告時,請在嘗試展現以前查看它是否已準備就緒。如下是一個在遊戲結束時展現插頁式廣告的示例。該應用必須在適當的時間顯式調用此方法。
- (void)gameOver {
if ([self.interstitial isReady]) {
[self.interstitial presentFromRootViewController:self];
}
// Rest of game over logic goes here.
}
KeyMob是最穩定最具效果的移動廣告平臺,致力於爲廣大開發者輕鬆實現安卓/IOS應用交叉推廣,更方便對移動營銷廣告進行高效的優化管理,爲開發者帶來更高的廣告收入。
app