AdMobのカスタムイベント(i-mobile用)

AdMobのカスタムイベントを作ってみました。

 

     1	//
     2	//  IMobileCustomEventBanner.h
     3	//
     4	//  Created by Keiichi Okamoto on 2013/05/09.
     5	//  Copyright (c) 2013 FuturesVision. All rights reserved.
     6	//
     7
     8	#import <UIKit/UIKit.h>
     9	#import "GADCustomEventBanner.h"
    10	#import "GADCustomEventBannerDelegate.h"
    11	#import "imobileAds/IMobileAdDelegateProtocol.h"
    12	#import "imobileAds/IMAdWhirlBannerView.h"
    13
    14
    15	@interface IMobileCustomEventBanner :NSObject 
    16
    17	@property (nonatomic, retain) IMAdWhirlBannerView *imAdView;
    18
    19	@end

 


 

     1	//
     2	//  IMobileCustomEventBanner.m
     3	//
     4	//  Created by Keiichi Okamoto on 2013/05/09.
     5	//  Copyright (c) 2013 FuturesVision. All rights reserved.
     6	//
     7
     8	#import "IMobileCustomEventBanner.h"
     9
    10
    11	@implementation IMobileCustomEventBanner
    12
    13	@synthesize delegate = __delegate;
    14	@synthesize imAdView = __imAdView;
    15
    16
    17	- (void)requestBannerAd:(GADAdSize)adSize
    18	              parameter:(NSString *)serverParameter
    19	                  label:(NSString *)serverLabel
    20	                request:(GADCustomEventRequest *)request {
    21
    22	    NSString* val;
    23	    int publisherId = 0;
    24	    int mediaId = 0;
    25	    int spotId = 0;
    26	    NSArray* array;
    27	    array = [serverParameter componentsSeparatedByString:@","];
    28	    @try {
    29	        val = [array objectAtIndex:0];
    30	        publisherId = [val integerValue];
    31	        val = [array objectAtIndex:1];
    32	        mediaId = [val integerValue];
    33	        val = [array objectAtIndex:2];
    34	        spotId = [val integerValue];
    35	    }
    36	    @catch (NSException *exception) {
    37	        return;
    38	    }
    39	
    40	    CGRect frame;
    41	    frame = CGRectMake(0, 0, kIMAdViewDefaultWidth, kIMAdViewDefaultHeight);
    42	    
    43	    __imAdView = [IMAdWhirlBannerView imAdWhirlBannerViewWithFrame:frame
    44	                                                      withDelegate:self
    45	                                                          testMode:NO];
    46	    [__imAdView retain];
    47	    [__imAdView setWithPublisherId:publisherId
    48	                           mediaId:mediaId
    49	                            spotId:spotId
    50	                          testMode:NO];
    51	    [__imAdView start];
    52	
    53	}
    54	
    55	- (void)dealloc
    56	{
    57	    self.delegate = nil;
    58	    [__imAdView release];
    59	
    60	    [super dealloc];
    61	}
    62	
    63	
    64	#pragma IMobileAdDelegate
    65	
    66	- (void)imAdViewDidFinishReceiveAd:(IMobileAdView *)imobileAdView {
    67	    CGRect frame;
    68	    frame = imobileAdView.frame;
    69	    [self.delegate customEventBanner:self didReceiveAd:imobileAdView];
    70	}
    71	
    72	- (void)imAdViewDidFailToReceiveAd:(IMobileAdView *)imobileAdView {
    73	    [self.delegate customEventBanner:self didFailAd:nil];
    74	}
    75	@end

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

CAPTCHA


WP-SpamFree by Pole Position Marketing