準備(参考)
プロジェクト右クリック→「Add Files to “プロジェクト名”」
SDKのAdd-ons,README.txt以外を追加
プロジェクト選択→「Build Phases」→「Link Binary With Library」で以下を追加
・MessageUI
・SystemConfiguration
・AdSupport
・AudioToolbox
・StoreKit
・AVFoundation
・CoreGraphics
プロジェクト選択→「Build Settings」→「Linking(Allを選択しないと表示されない)」→「Other Linker Flags」で以下を設定
-ObjC
バナー広告(参考)
1 2 3 4 5 6 7 |
//ヘッダ #import "GADBannerView.h" //banner @interface ViewController : UIViewController { //banner GADBannerView *bannerView_; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
//ソース - (void)viewDidLoad { [super viewDidLoad]; //banner bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait]; //縦画面用 bannerView_.adUnitID = @"UNITID"; bannerView_.rootViewController = self; [self.view addSubview:bannerView_]; GADRequest *request = [GADRequest request]; //request.testDevices = [NSArray arrayWithObjects:@[ GAD_SIMULATOR_ID ], @"端末ID", nil]; request.testDevices = @[ GAD_SIMULATOR_ID ]; [bannerView_ loadRequest:request]; } |
インタースティシャル広告(参考)
1 2 3 4 5 6 7 |
//ヘッダ #import "GADInterstitial.h" //interstitial @interface ViewController : UIViewController <GADInterstitialDelegate> { //interstitial GADInterstitial *interstitial_; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
//ソース - (void)viewDidLoad { [super viewDidLoad]; //interstitial GADRequest *request = [GADRequest request]; //request.testDevices = [NSArray arrayWithObjects:@[ GAD_SIMULATOR_ID ], @"端末ID", nil]; request.testDevices = @[ GAD_SIMULATOR_ID ]; interstitial_ = [[GADInterstitial alloc] init]; interstitial_.adUnitID = @"UNITID"; interstitial_.delegate = self; [interstitial_ loadRequest:request]; } - (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial { //準備ができたら表示 [interstitial_ presentFromRootViewController:self]; } |
端末IDの取得
Window → Organizer → Devies → 当該端末 → Identifier