Difference between revisions of "IOS AdMM"

From AdLocus
Jump to: navigation, search
(Created page with "== 前言 == 我們提供您透過 AdMob Mediation 來管理 InApp 的廣告版位。 == 專案設定 == *  將『AdMob Mediation Adapterr』...")
 
(→‎專案設定)
Line 5: Line 5:
 
*  將『[[Media:IOSAdLocusAdapter.zip|AdMob Mediation Adapter]]r』『[https://developers.google.com/admob/ios/download Google Mobile Ads SDK]』『[[Media:LibAdLocus_SDK_4_0_15.zip|AdLocus SDK]]』加入您的專案
 
*  將『[[Media:IOSAdLocusAdapter.zip|AdMob Mediation Adapter]]r』『[https://developers.google.com/admob/ios/download Google Mobile Ads SDK]』『[[Media:LibAdLocus_SDK_4_0_15.zip|AdLocus SDK]]』加入您的專案
 
[[File:Ios_mediation_project_step.jpg]]
 
[[File:Ios_mediation_project_step.jpg]]
 +
 +
* 在ViewController中加入以下程式碼
 +
<syntaxhighlight lang="c">
 +
/***************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];
 +
  [self GADInterstitial];
 +
}
 +
 +
-(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];
 +
}
 +
 +
- (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
 +
{
 +
   
 +
}
 +
 +
 +
@end
 +
</syntaxhighlight>
  
 
== AdMob 設定 ==
 
== AdMob 設定 ==

Revision as of 19:00, 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];
  [self GADInterstitial];
}
 
-(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];
}
 
- (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
{
 
}
 
 
@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 的廣告.