adding adNetwork SDKs for AdWhirl and AdMob
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// GADBannerView.h
|
||||
// Google AdMob Ads SDK
|
||||
//
|
||||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "GADRequest.h"
|
||||
#import "GADRequestError.h"
|
||||
#import "GADBannerViewDelegate.h"
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Ad Sizes
|
||||
|
||||
// iPhone and iPod Touch ad size.
|
||||
#define GAD_SIZE_320x50 CGSizeMake(320, 50)
|
||||
|
||||
// Medium Rectangle size for the iPad (especially in a UISplitView's left pane).
|
||||
#define GAD_SIZE_300x250 CGSizeMake(300, 250)
|
||||
|
||||
// Full Banner size for the iPad (especially in a UIPopoverController or in
|
||||
// UIModalPresentationFormSheet).
|
||||
#define GAD_SIZE_468x60 CGSizeMake(468, 60)
|
||||
|
||||
// Leaderboard size for the iPad.
|
||||
#define GAD_SIZE_728x90 CGSizeMake(728, 90)
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Banner Ad View
|
||||
|
||||
// The view that displays banner ads. A minimum implementation to get an ad
|
||||
// from within a UIViewController class is:
|
||||
//
|
||||
// // Place an ad at the top of the screen of an iPhone/iPod Touch.
|
||||
// CGRect adFrame = CGRectZero;
|
||||
// adFrame.size = GAD_SIZE_320x50;
|
||||
//
|
||||
// // Create and setup the ad view.
|
||||
// GADBannerView *adView = [[GADBannerView alloc] initWithFrame:adFrame];
|
||||
// adView.rootViewController = self;
|
||||
// adView.adUnitID = @"ID created when registering my app";
|
||||
//
|
||||
// // Place the ad view onto the screen.
|
||||
// [self.view addSubview:adView];
|
||||
// [adView release];
|
||||
//
|
||||
// // Request an ad without any additional targeting information.
|
||||
// [adView loadRequest:nil];
|
||||
//
|
||||
@interface GADBannerView : UIView
|
||||
|
||||
#pragma mark Pre-Request
|
||||
|
||||
// Required value created in the AdSense website. Create a new ad unit for
|
||||
// every unique placement of an ad in your application. Set this to the ID
|
||||
// assigned for this placement. Ad units are important for targeting and stats.
|
||||
// Example values for different request types:
|
||||
// AdMob: a0123456789ABCD
|
||||
// DFP: /0123/ca-pub-0123456789012345/my-ad-identifier
|
||||
// AdSense: ca-mb-app-pub-0123456789012345/my-ad-identifier
|
||||
// Mediation: AB123456789ABCDE
|
||||
@property (nonatomic, copy) NSString *adUnitID;
|
||||
|
||||
// Required reference to the current root view controller. For example the root
|
||||
// view controller in tab-based application would be the UITabViewController.
|
||||
@property (nonatomic, assign) UIViewController *rootViewController;
|
||||
|
||||
// Optional delegate object that receives state change notifications from this
|
||||
// GADBannerView. Typically this is a UIViewController, however, if you are
|
||||
// unfamiliar with the delegate pattern it is recommended you subclass this
|
||||
// GADBannerView and make it the delegate. That avoids any chance of your
|
||||
// application crashing if you forget to nil out the delegate. For example:
|
||||
//
|
||||
// @interface MyAdView : GADBannerView <GADBannerViewDelegate>
|
||||
// @end
|
||||
//
|
||||
// @implementation MyAdView
|
||||
// - (id)initWithFrame:(CGRect)frame {
|
||||
// if ((self = [super initWithFrame:frame])) {
|
||||
// self.delegate = self;
|
||||
// }
|
||||
// return self;
|
||||
// }
|
||||
//
|
||||
// - (void)dealloc {
|
||||
// self.delegate = nil;
|
||||
// [super dealloc];
|
||||
// }
|
||||
//
|
||||
// @end
|
||||
//
|
||||
@property (nonatomic, assign) NSObject<GADBannerViewDelegate> *delegate;
|
||||
|
||||
#pragma mark Making an Ad Request
|
||||
|
||||
// Makes an ad request. Additional targeting options can be supplied with a
|
||||
// request object. Refresh the ad by calling this method again.
|
||||
- (void)loadRequest:(GADRequest *)request;
|
||||
|
||||
#pragma mark Ad Request
|
||||
|
||||
// YES, if the currently displayed ad (or most recent failure) was a result of
|
||||
// auto refreshing as specified on server. This will be set to NO after each
|
||||
// loadRequest: method.
|
||||
@property (nonatomic, readonly) BOOL hasAutoRefreshed;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// GADBannerViewDelegate.h
|
||||
// Google AdMob Ads SDK
|
||||
//
|
||||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class GADRequestError;
|
||||
@class GADBannerView;
|
||||
|
||||
// Delegate for receiving state change messages from a GADBannerView such as ad
|
||||
// requests succeeding/failing or when an ad has been clicked.
|
||||
@protocol GADBannerViewDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
#pragma mark Ad Request Lifecycle Notifications
|
||||
|
||||
// Sent when an ad request loaded an ad. This is a good opportunity to add this
|
||||
// view to the hierarchy if it has not yet been added. If the ad was received
|
||||
// as a part of the server-side auto refreshing, you can examine the
|
||||
// hasAutoRefreshed property of the view.
|
||||
- (void)adViewDidReceiveAd:(GADBannerView *)view;
|
||||
|
||||
// Sent when an ad request failed. Normally this is because no network
|
||||
// connection was available or no ads were available (i.e. no fill). If the
|
||||
// error was received as a part of the server-side auto refreshing, you can
|
||||
// examine the hasAutoRefreshed property of the view.
|
||||
- (void)adView:(GADBannerView *)view
|
||||
didFailToReceiveAdWithError:(GADRequestError *)error;
|
||||
|
||||
#pragma mark Click-Time Lifecycle Notifications
|
||||
|
||||
// Sent just before presenting the user a full screen view, such as a browser,
|
||||
// in response to clicking on an ad. Use this opportunity to stop animations,
|
||||
// time sensitive interactions, etc.
|
||||
//
|
||||
// Normally the user looks at the ad, dismisses it, and control returns to your
|
||||
// application by calling adViewDidDismissScreen:. However if the user hits the
|
||||
// Home button or clicks on an App Store link your application will end. On iOS
|
||||
// 4.0+ the next method called will be applicationWillResignActive: of your
|
||||
// UIViewController (UIApplicationWillResignActiveNotification). Immediately
|
||||
// after that adViewWillLeaveApplication: is called.
|
||||
- (void)adViewWillPresentScreen:(GADBannerView *)adView;
|
||||
|
||||
// Sent just before dismissing a full screen view.
|
||||
- (void)adViewWillDismissScreen:(GADBannerView *)adView;
|
||||
|
||||
// Sent just after dismissing a full screen view. Use this opportunity to
|
||||
// restart anything you may have stopped as part of adViewWillPresentScreen:.
|
||||
- (void)adViewDidDismissScreen:(GADBannerView *)adView;
|
||||
|
||||
// Sent just before the application will background or terminate because the
|
||||
// user clicked on an ad that will launch another application (such as the App
|
||||
// Store). The normal UIApplicationDelegate methods, like
|
||||
// applicationDidEnterBackground:, will be called immediately before this.
|
||||
- (void)adViewWillLeaveApplication:(GADBannerView *)adView;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// GADInterstitial.h
|
||||
// Google AdMob Ads SDK
|
||||
//
|
||||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "GADInterstitialDelegate.h"
|
||||
#import "GADRequest.h"
|
||||
#import "GADRequestError.h"
|
||||
|
||||
// An interstitial ad. This is a full-screen advertisement shown at natural
|
||||
// transition points in your application such as between game levels or news
|
||||
// stories.
|
||||
//
|
||||
// Interstitials are shown sparingly. Expect low to no fill.
|
||||
@interface GADInterstitial : NSObject
|
||||
|
||||
#pragma mark Pre-Request
|
||||
|
||||
// Required value created in the AdSense website. Create a new ad unit for
|
||||
// every unique placement of an ad in your application. Set this to the ID
|
||||
// assigned for this placement. Ad units are important for targeting and stats.
|
||||
// Example values for different request types:
|
||||
// AdMob: a0123456789ABCD
|
||||
// DFP: /0123/ca-pub-0123456789012345/my-ad-identifier
|
||||
// AdSense: ca-mb-app-pub-0123456789012345/my-ad-identifier
|
||||
@property (nonatomic, copy) NSString *adUnitID;
|
||||
|
||||
// Optional delegate object that receives state change notifications from this
|
||||
// GADInterstitalAd. Remember to nil the delegate before deallocating this
|
||||
// object.
|
||||
@property (nonatomic, assign) NSObject<GADInterstitialDelegate> *delegate;
|
||||
|
||||
#pragma mark Making an Ad Request
|
||||
|
||||
// Makes an interstitial ad request. Additional targeting options can be
|
||||
// supplied with a request object. Only one interstitial request is allowed at
|
||||
// a time.
|
||||
//
|
||||
// This is best to do several seconds before the interstitial is needed to
|
||||
// preload its content. Then when transitioning between view controllers show
|
||||
// the interstital with presentFromViewController.
|
||||
- (void)loadRequest:(GADRequest *)request;
|
||||
|
||||
#pragma mark Request at Application Launch
|
||||
|
||||
// The |window| will be shown with the |image| displayed until either the
|
||||
// |request| interstitial is shown or a timeout occurs. The delegate will
|
||||
// receive an interstitialDidDismissScreen: callback to indicate that your app
|
||||
// should continue when the interstitial has finished.
|
||||
- (void)loadAndDisplayRequest:(GADRequest *)request
|
||||
usingWindow:(UIWindow *)window
|
||||
initialImage:(UIImage *)image;
|
||||
|
||||
#pragma mark Post-Request
|
||||
|
||||
// Returns YES if the interstitial is ready to be displayed. The delegate's
|
||||
// interstitialAdDidReceiveAd: will be called when this switches from NO to YES.
|
||||
@property (nonatomic, readonly) BOOL isReady;
|
||||
|
||||
// Returns YES if the interstitial object has already shown an interstitial.
|
||||
// Note that an interstitial object can only be used once even with different
|
||||
// requests.
|
||||
@property (nonatomic, readonly) BOOL hasBeenUsed;
|
||||
|
||||
// Presents the interstitial ad which takes over the entire screen until the
|
||||
// user dismisses it. This has no effect unless isReady returns YES and/or the
|
||||
// delegate's interstitialDidReceiveAd: has been received.
|
||||
//
|
||||
// Set rootViewController to the current view controller at the time this method
|
||||
// is called. If your application does not use view controllers pass in nil and
|
||||
// your views will be removed from the window to show the interstitial and
|
||||
// restored when done. After the interstitial has been removed, the delegate's
|
||||
// interstitialDidDismissScreen: will be called.
|
||||
- (void)presentFromRootViewController:(UIViewController *)rootViewController;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// GADInterstitialDelegate.h
|
||||
// Google AdMob Ads SDK
|
||||
//
|
||||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class GADInterstitial;
|
||||
@class GADRequestError;
|
||||
|
||||
// Delegate for receiving state change messages from a GADInterstitial such as
|
||||
// interstitial ad requests succeeding/failing.
|
||||
@protocol GADInterstitialDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
#pragma mark Ad Request Lifecycle Notifications
|
||||
|
||||
// Sent when an interstitial ad request succeeded. Show it at the next
|
||||
// transition point in your application such as when transitioning between view
|
||||
// controllers.
|
||||
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad;
|
||||
|
||||
// Sent when an interstitial ad request completed without an interstitial to
|
||||
// show. This is common since interstitials are shown sparingly to users.
|
||||
- (void)interstitial:(GADInterstitial *)ad
|
||||
didFailToReceiveAdWithError:(GADRequestError *)error;
|
||||
|
||||
#pragma mark Display-Time Lifecycle Notifications
|
||||
|
||||
// Sent just before presenting an interstitial. After this method finishes the
|
||||
// interstitial will animate onto the screen. Use this opportunity to stop
|
||||
// animations and save the state of your application in case the user leaves
|
||||
// while the interstitial is on screen (e.g. to visit the App Store from a link
|
||||
// on the interstitial).
|
||||
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad;
|
||||
|
||||
// Sent before the interstitial is to be animated off the screen.
|
||||
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad;
|
||||
|
||||
// Sent just after dismissing an interstitial and it has animated off the
|
||||
// screen.
|
||||
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad;
|
||||
|
||||
// Sent just before the application will background or terminate because the
|
||||
// user clicked on an ad that will launch another application (such as the App
|
||||
// Store). The normal UIApplicationDelegate methods, like
|
||||
// applicationDidEnterBackground:, will be called immediately before this.
|
||||
- (void)interstitialWillLeaveApplication:(GADInterstitial *)ad;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// GADRequest.h
|
||||
// Google AdMob Ads SDK
|
||||
//
|
||||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// Constant for getting test ads on the simulator using the testDevices method.
|
||||
#define GAD_SIMULATOR_ID @"Simulator"
|
||||
|
||||
// Genders to help deliver more relevant ads.
|
||||
typedef enum {
|
||||
kGADGenderUnknown,
|
||||
kGADGenderMale,
|
||||
kGADGenderFemale
|
||||
} GADGender;
|
||||
|
||||
// Specifies optional parameters for ad requests.
|
||||
@interface GADRequest : NSObject <NSCopying>
|
||||
|
||||
// Creates an autoreleased GADRequest.
|
||||
+ (GADRequest *)request;
|
||||
|
||||
// Passes extra details in ad requests.
|
||||
//
|
||||
// One case is for Ad Network Mediation. Some Ad Networks may ask for additional
|
||||
// information about the ad request. Consult with the individual Ad Network
|
||||
// on what to send. Place the information in a dictionary and put that in
|
||||
// another dictionary under the key "mediation". An example might be:
|
||||
//
|
||||
// additionalParameters = {
|
||||
// mediation: {
|
||||
// MyAdNetwork: {
|
||||
// market_segment: "abc",
|
||||
// some_info: "xyz",
|
||||
// some_num: 1000
|
||||
// },
|
||||
// AdNetworkX: {
|
||||
// key1: "val1",
|
||||
// key2: "val2"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// To create such a dictionary, do the following:
|
||||
//
|
||||
// NSDictionary *myAdNetwork = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
// @"abc", @"market_segment",
|
||||
// @"xyz", @"some_info",
|
||||
// [NSNumber numberWithInt:1000], @"some_num",
|
||||
// nil];
|
||||
// NSDictionary *adNetwokX = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
// @"val1", @"key1",
|
||||
// @"val2", @"key2",
|
||||
// nil];
|
||||
// NSDictionary *mediation = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
// myAdNetwork, @"MyAdNetwork",
|
||||
// adNetwokX, @"AdNetworkX",
|
||||
// nil];
|
||||
// NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
// mediation, @"mediation",
|
||||
// nil];
|
||||
// gadRequest.additionalParameters = params;
|
||||
@property (nonatomic, retain) NSDictionary *additionalParameters;
|
||||
|
||||
#pragma mark Collecting SDK Information
|
||||
|
||||
// Returns the version of the SDK.
|
||||
+ (NSString *)sdkVersion;
|
||||
|
||||
#pragma mark Testing
|
||||
|
||||
// Test ads are returned to these devices. Device identifiers are the same used
|
||||
// to register as a development device with Apple. To obtain a value open the
|
||||
// Organizer (Window -> Organizer from Xcode), control-click or right-click on
|
||||
// the device's name, and choose "Copy Device Identifier". Alternatively you
|
||||
// can obtain it through code using [[UIDevice currentDevice] uniqueIdentifier].
|
||||
//
|
||||
// For example:
|
||||
// request.testDevices = [NSArray arrayWithObjects:
|
||||
// GAD_SIMULATOR_ID, // Simulator
|
||||
// //@"28ab37c3902621dd572509110745071f0101b124", // Test iPhone 3G 3.0.1
|
||||
// @"8cf09e81ef3ec5418c3450f7954e0e95db8ab200", // Test iPod 4.3.1
|
||||
// nil];
|
||||
@property (nonatomic, retain) NSArray *testDevices;
|
||||
|
||||
#pragma mark User Information
|
||||
|
||||
// The user's gender may be used to deliver more relevant ads.
|
||||
@property (nonatomic, assign) GADGender gender;
|
||||
|
||||
// The user's birthday may be used to deliver more relevant ads.
|
||||
@property (nonatomic, retain) NSDate *birthday;
|
||||
- (void)setBirthdayWithMonth:(NSInteger)m day:(NSInteger)d year:(NSInteger)y;
|
||||
|
||||
// The user's current location may be used to deliver more relevant ads.
|
||||
// However do not use Core Location just for advertising, make sure it is used
|
||||
// for more beneficial reasons as well. It is both a good idea and part of
|
||||
// Apple's guidelines.
|
||||
- (void)setLocationWithLatitude:(CGFloat)latitude longitude:(CGFloat)longitude
|
||||
accuracy:(CGFloat)accuracyInMeters;
|
||||
|
||||
// When Core Location isn't available but the user's location is known supplying
|
||||
// it here may deliver more relevant ads. It can be any free-form text such as
|
||||
// @"Champs-Elysees Paris" or @"94041 US".
|
||||
- (void)setLocationWithDescription:(NSString *)locationDescription;
|
||||
|
||||
#pragma mark Contextual Information
|
||||
|
||||
// A keyword is a word or phrase describing the current activity of the user
|
||||
// such as @"Sports Scores". Each keyword is an NSString in the NSArray. To
|
||||
// clear the keywords set this to nil.
|
||||
@property (nonatomic, retain) NSMutableArray *keywords;
|
||||
|
||||
// Convenience method for adding keywords one at a time such as @"Sports Scores"
|
||||
// and then @"Football".
|
||||
- (void)addKeyword:(NSString *)keyword;
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Deprecated Methods
|
||||
|
||||
// Please use testDevices instead.
|
||||
@property (nonatomic, getter=isTesting) BOOL testing;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// GADRequestError.h
|
||||
// Google AdMob Ads SDK
|
||||
//
|
||||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class GADRequest;
|
||||
|
||||
extern NSString *kGADErrorDomain;
|
||||
|
||||
// NSError codes for GAD error domain.
|
||||
typedef enum {
|
||||
// The ad request is invalid. The localizedFailureReason error description
|
||||
// will have more details. Typically this is because the ad did not have the
|
||||
// ad unit ID or root view controller set.
|
||||
kGADErrorInvalidRequest,
|
||||
|
||||
// The ad request was successful, but no ad was returned.
|
||||
kGADErrorNoFill,
|
||||
|
||||
// There was an error loading data from the network.
|
||||
kGADErrorNetworkError,
|
||||
|
||||
// The ad server experienced a failure processing the request.
|
||||
kGADErrorServerError,
|
||||
|
||||
// The current device's OS is below the minimum required version.
|
||||
kGADErrorOSVersionTooLow,
|
||||
|
||||
// The request was unable to be loaded before being timed out.
|
||||
kGADErrorTimeout,
|
||||
|
||||
// Will not send request because the interstitial object has already been
|
||||
// used.
|
||||
kGADErrorInterstitialAlreadyUsed,
|
||||
|
||||
// The mediation request encountered an error.
|
||||
kGADMediationError,
|
||||
|
||||
} GADErrorCode;
|
||||
|
||||
// This class represents the error generated due to invalid request parameters.
|
||||
@interface GADRequestError : NSError
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
============================
|
||||
Google AdMob Ads SDK for iOS
|
||||
============================
|
||||
|
||||
This is the Google AdMob Ads SDK for iOS.
|
||||
|
||||
Requirements:
|
||||
- An AdMob site ID, AdSense client ID, or DoubleClick for Publishers account
|
||||
- Xcode 4.2 or later.
|
||||
- Runtime of iOS 3.0 or later.
|
||||
|
||||
The latest documentation and code samples are available at:
|
||||
http://code.google.com/mobile/ads/docs/ios
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user