Difference between revisions of "IOS AdMM"

From AdLocus
Jump to: navigation, search
(→‎專案設定)
(→‎專案設定)
Line 32: Line 32:
 
   [super viewDidLoad];
 
   [super viewDidLoad];
 
   [self GADBanner];
 
   [self GADBanner];
−
  [self GADInterstitial];
+
 
 
}
 
}
  
Line 45: Line 45:
 
}
 
}
  
−
- (void)GADInterstitial
 
−
{
 
−
    self.interstitialView = [[GADInterstitial alloc] init];
 
−
    self.interstitialView.adUnitID = @"your ad unit ID";
 
−
    self.interstitialView.delegate = self;
 
−
    [self.interstitialView loadRequest:[[GADInterstitial alloc] init]];
 
−
}
 
−
 
−
#pragma GADInterstitial Delegate
 
−
 
−
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad
 
−
{
 
−
    [self.interstitialView presentFromRootViewController:self]; //  Present interstitial Ad.
 
−
}
 
−
 
−
- (void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error
 
−
{
 
−
    //NSLog(@"Failed to receive : %@", error.localizedDescription);
 
−
}
 
−
 
−
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad
 
−
{
 
−
   
 
−
}
 
−
 
−
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad
 
−
{
 
−
   
 
−
}
 
−
 
−
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad
 
−
{
 
−
   
 
−
}
 
−
 
−
- (void)interstitialWillLeaveApplication:(GADInterstitial *)ad
 
−
{
 
−
   
 
−
}
 
  
  

Revision as of 19:04, 15 July 2015

前言

我們提供您透過 AdMob Mediation 來管理 InApp 的廣告版位。

專案設定

Ios mediation project step.jpg

  • 在ViewController中加入以下程式碼
/***************ViewController.h****************/
#import <UIKit/UIKit.h>
#import "GoogleMobileAds/GADInterstitial.h"
@class GADBannerView;
 
@interface ViewController : UIViewController<GADBannerViewDelegate, GADInterstitialDelegate>
 
@property(nonatomic, weak) IBOutlet GADBannerView *bannerView;
@property (nonatomic, retain) GADInterstitial *interstitialView;
 
@end
 
 
/***************ViewController.m****************/
@import GoogleMobileAds;
 
#import "ViewController.h"
 
@implementation ViewController
 
- (void)viewDidLoad
{
  [super viewDidLoad];
  [self GADBanner];
 
}
 
-(void)GADBanner
{
    self.bannerView.adUnitID = @"your ad unit ID";
    self.bannerView.rootViewController = self;
    GADRequest *request = [GADRequest request];
 
    //request.testDevices = @[@"your device id"];
    [self.bannerView loadRequest:request];
}
 
 
 
@end

AdMob 設定

  • 在 App 的 [設定頁面] 中, 點選 [編輯中介服務]
 Mediation3.jpg
  • 在 [中介服務] 中, 點選 [新增廣告聯播網]
  • 在 [廣告聯播網] 中, 點選 [新增自訂事件]
 Mediation2.jpg
  • ClassName 輸入: com.adlocus.AdLocusAdapter
  • Parameter 輸入: 您的AdLocus APP Key
  • Label 輸入: AdLocus
  • 選擇 [繼續]
 Mediation1.jpg
  • 儲存後, 在 [中介服務] 中, 調整 AdLocus 的 CPM 為 1.00 USD, 可優先取得 AdLocus 的廣告.