mirror of https://github.com/axmolengine/axmol.git
Add plugin Admob for iOS.
This commit is contained in:
parent
12d83f543b
commit
6da209331f
|
@ -52,6 +52,7 @@ public class AdsAdmob implements InterfaceAds {
|
|||
private static final int ADMOB_SIZE_IABMRect = 1;
|
||||
private static final int ADMOB_SIZE_IABBanner = 2;
|
||||
private static final int ADMOB_SIZE_IABLeaderboard = 3;
|
||||
private static final int ADMOB_SIZE_Skyscraper = 4;
|
||||
|
||||
protected static void LogE(String msg, Exception e) {
|
||||
Log.e(LOG_TAG, msg, e);
|
||||
|
@ -152,6 +153,9 @@ public class AdsAdmob implements InterfaceAds {
|
|||
case AdsAdmob.ADMOB_SIZE_IABLeaderboard:
|
||||
size = AdSize.IAB_LEADERBOARD;
|
||||
break;
|
||||
case AdsAdmob.ADMOB_SIZE_Skyscraper:
|
||||
size = AdSize.IAB_WIDE_SKYSCRAPER;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// GADAdMobExtras.h
|
||||
// Google Ads iOS SDK
|
||||
//
|
||||
// Copyright (c) 2012 Google Inc. All rights reserved.
|
||||
//
|
||||
// The additional parameters publishers may send to the AdMob network.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "GADAdNetworkExtras.h"
|
||||
|
||||
@interface GADAdMobExtras : NSObject <GADAdNetworkExtras>
|
||||
|
||||
@property (nonatomic, retain) NSDictionary *additionalParameters;
|
||||
|
||||
@end
|
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// GADAdNetworkExtras.h
|
||||
// Google Ads iOS SDK
|
||||
//
|
||||
// Copyright (c) 2012 Google Inc. All rights reserved.
|
||||
//
|
||||
// An object implementing this protocol contains information set by the
|
||||
// publisher on the client device for a particular ad network.
|
||||
//
|
||||
// Ad networks should create an 'extras' object implementing this protocol for
|
||||
// their publishers to use.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol GADAdNetworkExtras <NSObject>
|
||||
|
||||
@end
|
|
@ -0,0 +1,92 @@
|
|||
//
|
||||
// GADAdSize.h
|
||||
// Google Ads iOS SDK
|
||||
//
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
//
|
||||
// A valid GADAdSize is considered to be one of the predefined GADAdSize
|
||||
// constants or a GADAdSize constructed by GADAdSizeFromCGSize,
|
||||
// GADAdSizeFullWidthPortraitWithHeight, GADAdSizeFullWidthLandscapeWithHeight.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
// Do not create a GADAdSize manually. Use one of the kGADAdSize constants.
|
||||
// Treat GADAdSize as an opaque type. Do not access any fields directly. To
|
||||
// obtain a concrete CGSize, use the function CGSizeFromGADAdSize().
|
||||
typedef struct GADAdSize {
|
||||
CGSize size;
|
||||
NSUInteger flags;
|
||||
} GADAdSize;
|
||||
|
||||
#pragma mark Standard Sizes
|
||||
|
||||
// iPhone and iPod Touch ad size. Typically 320x50.
|
||||
extern GADAdSize const kGADAdSizeBanner;
|
||||
|
||||
// Medium Rectangle size for the iPad (especially in a UISplitView's left pane).
|
||||
// Typically 300x250.
|
||||
extern GADAdSize const kGADAdSizeMediumRectangle;
|
||||
|
||||
// Full Banner size for the iPad (especially in a UIPopoverController or in
|
||||
// UIModalPresentationFormSheet). Typically 468x60.
|
||||
extern GADAdSize const kGADAdSizeFullBanner;
|
||||
|
||||
// Leaderboard size for the iPad. Typically 728x90.
|
||||
extern GADAdSize const kGADAdSizeLeaderboard;
|
||||
|
||||
// Skyscraper size for the iPad. Mediation only. AdMob/Google does not offer
|
||||
// this size. Typically 120x600.
|
||||
extern GADAdSize const kGADAdSizeSkyscraper;
|
||||
|
||||
// An ad size that spans the full width of the application in portrait
|
||||
// orientation. The height is typically 50 pixels on an iPhone/iPod UI, and 90
|
||||
// pixels tall on an iPad UI.
|
||||
extern GADAdSize const kGADAdSizeSmartBannerPortrait;
|
||||
|
||||
// An ad size that spans the full width of the application in landscape
|
||||
// orientation. The height is typically 32 pixels on an iPhone/iPod UI, and 90
|
||||
// pixels tall on an iPad UI.
|
||||
extern GADAdSize const kGADAdSizeSmartBannerLandscape;
|
||||
|
||||
// Invalid ad size marker.
|
||||
extern GADAdSize const kGADAdSizeInvalid;
|
||||
|
||||
#pragma mark Custom Sizes
|
||||
|
||||
// Given a CGSize, return a custom GADAdSize. Use this only if you require a
|
||||
// non-standard size, otherwise, use one of the standard size constants above.
|
||||
GADAdSize GADAdSizeFromCGSize(CGSize size);
|
||||
|
||||
// Get a custom GADAdSize that spans the full width of the application in
|
||||
// portrait orientation with the height provided.
|
||||
GADAdSize GADAdSizeFullWidthPortraitWithHeight(CGFloat height);
|
||||
|
||||
// Get a custom GADAdSize that spans the full width of the application in
|
||||
// landscape orientation with the height provided.
|
||||
GADAdSize GADAdSizeFullWidthLandscapeWithHeight(CGFloat height);
|
||||
|
||||
#pragma mark Convenience Functions
|
||||
|
||||
// Checks whether the two GADAdSizes are equal.
|
||||
BOOL GADAdSizeEqualToSize(GADAdSize size1, GADAdSize size2);
|
||||
|
||||
// Given a GADAdSize constant, returns a CGSize. If the GADAdSize is unknown,
|
||||
// returns CGSizeZero.
|
||||
CGSize CGSizeFromGADAdSize(GADAdSize size);
|
||||
|
||||
// Determines if |size| is one of the predefined constants, or a custom
|
||||
// GADAdSize generated by FromCGSize.
|
||||
BOOL IsGADAdSizeValid(GADAdSize size);
|
||||
|
||||
// Given a GADAdSize constant, returns a NSString describing the GADAdSize.
|
||||
NSString *NSStringFromGADAdSize(GADAdSize size);
|
||||
|
||||
|
||||
#pragma mark Deprecated Macros
|
||||
|
||||
#define GAD_SIZE_320x50 CGSizeFromGADAdSize(kGADAdSizeBanner)
|
||||
#define GAD_SIZE_300x250 CGSizeFromGADAdSize(kGADAdSizeMediumRectangle)
|
||||
#define GAD_SIZE_468x60 CGSizeFromGADAdSize(kGADAdSizeFullBanner)
|
||||
#define GAD_SIZE_728x90 CGSizeFromGADAdSize(kGADAdSizeLeaderboard)
|
||||
#define GAD_SIZE_120x600 CGSizeFromGADAdSize(kGADAdSizeSkyscraper)
|
|
@ -0,0 +1,114 @@
|
|||
//
|
||||
// GADBannerView.h
|
||||
// Google AdMob Ads SDK
|
||||
//
|
||||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "GADAdSize.h"
|
||||
#import "GADRequest.h"
|
||||
#import "GADRequestError.h"
|
||||
#import "GADBannerViewDelegate.h"
|
||||
|
||||
// The view that displays banner ads. A minimum implementation to get an ad
|
||||
// from within a UIViewController class is:
|
||||
//
|
||||
// // Create and setup the ad view, specifying the size and origin at {0, 0}.
|
||||
// GADBannerView *adView =
|
||||
// [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
|
||||
// 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 Initialization
|
||||
|
||||
// Initializes a GADBannerView and sets it to the specified size, and specifies
|
||||
// its placement within its superview bounds. If |size| is invalid, an
|
||||
// instance of GADBannerView is not created and nil is returned instead.
|
||||
- (id)initWithAdSize:(GADAdSize)size origin:(CGPoint)origin;
|
||||
|
||||
// Initializes a GADBannerView and sets it to the specified size, and specifies
|
||||
// its placement at the top left of its superview. If |size| is invalid, an
|
||||
// instance of GADBannerView is not created and nil is returned instead.
|
||||
- (id)initWithAdSize:(GADAdSize)size;
|
||||
|
||||
#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;
|
||||
|
||||
// Required to set this banner view to a proper size. Never create your own
|
||||
// GADAdSize directly. Use one of the predefined standard ad sizes
|
||||
// (such as kGADAdSizeBanner), or create one using the GADAdSizeFromCGSize
|
||||
// method. If not using mediation, then changing the adSize after an ad has
|
||||
// been shown will cause a new request (for an ad of the new size) to be sent.
|
||||
// If using mediation, then a new request may not be sent.
|
||||
@property (nonatomic) GADAdSize adSize;
|
||||
|
||||
// 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;
|
||||
|
||||
#pragma mark Mediation
|
||||
|
||||
// Gets the underlying ad view of the mediated ad network.
|
||||
// You may use this to find out the actual size of the ad and adjust
|
||||
// GADBannerView to fit the underlying ad view.
|
||||
@property (nonatomic, readonly) UIView *mediatedAdView;
|
||||
|
||||
@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,105 @@
|
|||
//
|
||||
// GADRequest.h
|
||||
// Google AdMob Ads SDK
|
||||
//
|
||||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol GADAdNetworkExtras;
|
||||
|
||||
// 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;
|
||||
|
||||
#pragma mark Additional Parameters For Ad Networks
|
||||
|
||||
// Ad networks may have additional parameters they accept. To pass these
|
||||
// parameters to them, create the ad network extras object for that network,
|
||||
// fill in the parameters, and register it here. The ad network should have a
|
||||
// header defining the interface for the 'extras' object to create. All
|
||||
// networks will have access to the basic settings you've set in this GADRequest
|
||||
// (gender, birthday, testing mode, etc.). If you register an extras object
|
||||
// that is the same class as one you have registered before, the previous
|
||||
// extras will be overwritten.
|
||||
- (void)registerAdNetworkExtras:(id<GADAdNetworkExtras>)extras;
|
||||
|
||||
// Get the network extras defined for an ad network.
|
||||
- (id<GADAdNetworkExtras>)adNetworkExtrasFor:(Class<GADAdNetworkExtras>)clazz;
|
||||
|
||||
// Unsets the extras for an ad network. |clazz| is the class which represents
|
||||
// that network's extras type.
|
||||
- (void)removeAdNetworkExtrasFor:(Class<GADAdNetworkExtras>)clazz;
|
||||
|
||||
// Extras sent to the mediation server (if using Mediation). For future use.
|
||||
@property (nonatomic, retain) NSDictionary *mediationExtras;
|
||||
|
||||
#pragma mark Collecting SDK Information
|
||||
|
||||
// Returns the version of the SDK.
|
||||
+ (NSString *)sdkVersion;
|
||||
|
||||
#pragma mark Testing
|
||||
|
||||
// Add the device's identifier into this array for testing purposes.
|
||||
@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
|
||||
|
||||
// Accesses the additionalParameters for the "GoogleAdmob" ad network. Please
|
||||
// use -registerAdNetworkExtras: method above and pass an instance of
|
||||
// GADAdMobExtras instead.
|
||||
@property (nonatomic, retain) NSDictionary *additionalParameters;
|
||||
|
||||
// This property has been deprecated with the latest SDK releases. Please use
|
||||
// testDevices.
|
||||
@property (nonatomic, getter=isTesting) BOOL testing;
|
||||
|
||||
@end
|
|
@ -0,0 +1,58 @@
|
|||
//
|
||||
// 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 response was invalid.
|
||||
kGADErrorMediationDataError,
|
||||
|
||||
// Error finding or creating a mediation ad network adapter.
|
||||
kGADErrorMediationAdapterError,
|
||||
|
||||
// The mediation request was successful, but no ad was returned from any
|
||||
// ad networks.
|
||||
kGADErrorMediationNoFill,
|
||||
|
||||
// Attempting to pass an invalid ad size to an adapter.
|
||||
kGADErrorMediationInvalidAdSize,
|
||||
|
||||
} GADErrorCode;
|
||||
|
||||
// This class represents the error generated due to invalid request parameters.
|
||||
@interface GADRequestError : NSError
|
||||
|
||||
@end
|
|
@ -0,0 +1 @@
|
|||
75b3945d48c14d4e433109c6c13a1e4bece6be68
|
|
@ -0,0 +1,63 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "InterfaceAds.h"
|
||||
#import "GADBannerView.h"
|
||||
#import "GADBannerViewDelegate.h"
|
||||
|
||||
typedef enum {
|
||||
kSizeBanner = 0,
|
||||
kSizeIABMRect,
|
||||
kSizeIABBanner,
|
||||
kSizeIABLeaderboard,
|
||||
kSizeSkyscraper,
|
||||
} AdmobSizeEnum;
|
||||
|
||||
@interface AdsAdmob : NSObject <InterfaceAds, GADBannerViewDelegate>
|
||||
{
|
||||
}
|
||||
|
||||
@property BOOL debug;
|
||||
@property (copy, nonatomic) NSString* strPublishID;
|
||||
@property (assign, nonatomic) GADBannerView* bannerView;
|
||||
@property (assign, nonatomic) NSMutableArray* testDeviceIDs;
|
||||
|
||||
/**
|
||||
interfaces from InterfaceAds
|
||||
*/
|
||||
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo;
|
||||
- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos;
|
||||
- (void) hideAds: (int) type;
|
||||
- (void) spendPoints: (int) points;
|
||||
- (void) setDebugMode: (BOOL) isDebugMode;
|
||||
- (NSString*) getSDKVersion;
|
||||
- (NSString*) getPluginVersion;
|
||||
|
||||
/**
|
||||
interface for Admob SDK
|
||||
*/
|
||||
- (void) addTestDevice: (NSString*) deviceID;
|
||||
|
||||
@end
|
|
@ -0,0 +1,176 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import "AdsAdmob.h"
|
||||
#import "AdsWrapper.h"
|
||||
|
||||
#define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__);
|
||||
|
||||
@implementation AdsAdmob
|
||||
|
||||
@synthesize debug = __debug;
|
||||
@synthesize strPublishID = __PublishID;
|
||||
@synthesize testDeviceIDs = __TestDeviceIDs;
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (self.bannerView != nil) {
|
||||
[self.bannerView release];
|
||||
self.bannerView = nil;
|
||||
}
|
||||
|
||||
if (self.testDeviceIDs != nil) {
|
||||
[self.testDeviceIDs release];
|
||||
self.testDeviceIDs = nil;
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
#pragma mark InterfaceAds impl
|
||||
|
||||
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo
|
||||
{
|
||||
self.strPublishID = (NSString*) [devInfo objectForKey:@"AdmobID"];
|
||||
}
|
||||
|
||||
- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos
|
||||
{
|
||||
if (self.strPublishID == nil ||
|
||||
[self.strPublishID length] == 0) {
|
||||
OUTPUT_LOG(@"configDeveloperInfo() not correctly invoked in Admob!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == kTypeBanner) {
|
||||
[self showBanner:sizeEnum atPos:pos];
|
||||
} else {
|
||||
OUTPUT_LOG(@"Now not support full screen view in Admob");
|
||||
}
|
||||
}
|
||||
|
||||
- (void) hideAds: (int) type
|
||||
{
|
||||
if (type == kTypeBanner) {
|
||||
if (nil != self.bannerView) {
|
||||
[self.bannerView removeFromSuperview];
|
||||
[self.bannerView release];
|
||||
self.bannerView = nil;
|
||||
}
|
||||
} else {
|
||||
OUTPUT_LOG(@"Now not support full screen view in Admob");
|
||||
}
|
||||
}
|
||||
|
||||
- (void) spendPoints: (int) points
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void) setDebugMode: (BOOL) isDebugMode
|
||||
{
|
||||
self.debug = isDebugMode;
|
||||
}
|
||||
|
||||
- (NSString*) getSDKVersion
|
||||
{
|
||||
return @"6.4.2";
|
||||
}
|
||||
|
||||
- (NSString*) getPluginVersion
|
||||
{
|
||||
return @"0.2.0";
|
||||
}
|
||||
|
||||
- (void) showBanner: (int) sizeEnum atPos:(int) pos
|
||||
{
|
||||
GADAdSize size;
|
||||
switch (sizeEnum) {
|
||||
case kSizeBanner:
|
||||
size = kGADAdSizeBanner;
|
||||
break;
|
||||
case kSizeIABMRect:
|
||||
size = kGADAdSizeMediumRectangle;
|
||||
break;
|
||||
case kSizeIABBanner:
|
||||
size = kGADAdSizeFullBanner;
|
||||
break;
|
||||
case kSizeIABLeaderboard:
|
||||
size = kGADAdSizeLeaderboard;
|
||||
break;
|
||||
case kSizeSkyscraper:
|
||||
size = kGADAdSizeSkyscraper;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (nil != self.bannerView) {
|
||||
[self.bannerView removeFromSuperview];
|
||||
[self.bannerView release];
|
||||
self.bannerView = nil;
|
||||
}
|
||||
|
||||
self.bannerView = [[GADBannerView alloc] initWithAdSize:size];
|
||||
self.bannerView.adUnitID = self.strPublishID;
|
||||
self.bannerView.delegate = self;
|
||||
[self.bannerView setRootViewController:[AdsWrapper getCurrentRootViewController]];
|
||||
[AdsWrapper addAdView:self.bannerView atPos:pos];
|
||||
|
||||
GADRequest* request = [GADRequest request];
|
||||
request.testDevices = [NSArray arrayWithArray:self.testDeviceIDs];
|
||||
[self.bannerView loadRequest:request];
|
||||
}
|
||||
|
||||
#pragma mark interface for Admob SDK
|
||||
|
||||
- (void) addTestDevice: (NSString*) deviceID
|
||||
{
|
||||
if (nil == self.testDeviceIDs) {
|
||||
self.testDeviceIDs = [NSMutableArray alloc];
|
||||
[self.testDeviceIDs addObject:GAD_SIMULATOR_ID];
|
||||
}
|
||||
[self.testDeviceIDs addObject:deviceID];
|
||||
}
|
||||
|
||||
#pragma mark GADBannerViewDelegate impl
|
||||
|
||||
// Since we've received an ad, let's go ahead and set the frame to display it.
|
||||
- (void)adViewDidReceiveAd:(GADBannerView *)adView {
|
||||
NSLog(@"Received ad");
|
||||
[AdsWrapper onAdsResult:self withRet:kAdsReceived withMsg:@"Ads request received success!"];
|
||||
}
|
||||
|
||||
- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error {
|
||||
NSLog(@"Failed to receive ad with error: %@", [error localizedFailureReason]);
|
||||
int errorNo = kUnknownError;
|
||||
switch ([error code]) {
|
||||
case kGADErrorNetworkError:
|
||||
errorNo = kNetworkError;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
[AdsWrapper onAdsResult:self withRet:errorNo withMsg:[error localizedDescription]];
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
//
|
||||
// Prefix header for all source files of the 'PluginAdmob' target in the 'PluginAdmob' project
|
||||
//
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
|
@ -0,0 +1,270 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
FADC44AB176EA82000B2D5ED /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FADC44AA176EA82000B2D5ED /* Foundation.framework */; };
|
||||
FADC44C5176EA84500B2D5ED /* libGoogleAdMobAds.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FADC44C2176EA84500B2D5ED /* libGoogleAdMobAds.a */; };
|
||||
FADC44C6176EA84500B2D5ED /* AdsAdmob.m in Sources */ = {isa = PBXBuildFile; fileRef = FADC44C4176EA84500B2D5ED /* AdsAdmob.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
FADC44A5176EA82000B2D5ED /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "include/${PRODUCT_NAME}";
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
FADC44A7176EA82000B2D5ED /* libPluginAdmob.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPluginAdmob.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
FADC44AA176EA82000B2D5ED /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
FADC44B9176EA84500B2D5ED /* GADAdMobExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADAdMobExtras.h; sourceTree = "<group>"; };
|
||||
FADC44BA176EA84500B2D5ED /* GADAdNetworkExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADAdNetworkExtras.h; sourceTree = "<group>"; };
|
||||
FADC44BB176EA84500B2D5ED /* GADAdSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADAdSize.h; sourceTree = "<group>"; };
|
||||
FADC44BC176EA84500B2D5ED /* GADBannerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADBannerView.h; sourceTree = "<group>"; };
|
||||
FADC44BD176EA84500B2D5ED /* GADBannerViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADBannerViewDelegate.h; sourceTree = "<group>"; };
|
||||
FADC44BE176EA84500B2D5ED /* GADInterstitial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADInterstitial.h; sourceTree = "<group>"; };
|
||||
FADC44BF176EA84500B2D5ED /* GADInterstitialDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADInterstitialDelegate.h; sourceTree = "<group>"; };
|
||||
FADC44C0176EA84500B2D5ED /* GADRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADRequest.h; sourceTree = "<group>"; };
|
||||
FADC44C1176EA84500B2D5ED /* GADRequestError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GADRequestError.h; sourceTree = "<group>"; };
|
||||
FADC44C2176EA84500B2D5ED /* libGoogleAdMobAds.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libGoogleAdMobAds.a; sourceTree = "<group>"; };
|
||||
FADC44C3176EA84500B2D5ED /* AdsAdmob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdsAdmob.h; sourceTree = "<group>"; };
|
||||
FADC44C4176EA84500B2D5ED /* AdsAdmob.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdsAdmob.m; sourceTree = "<group>"; };
|
||||
FADC44C7176EA85F00B2D5ED /* PluginAdmob-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PluginAdmob-Prefix.pch"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
FADC44A4176EA82000B2D5ED /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
FADC44AB176EA82000B2D5ED /* Foundation.framework in Frameworks */,
|
||||
FADC44C5176EA84500B2D5ED /* libGoogleAdMobAds.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
FADC449E176EA82000B2D5ED = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FADC44C7176EA85F00B2D5ED /* PluginAdmob-Prefix.pch */,
|
||||
FADC44B8176EA84500B2D5ED /* Admob */,
|
||||
FADC44C3176EA84500B2D5ED /* AdsAdmob.h */,
|
||||
FADC44C4176EA84500B2D5ED /* AdsAdmob.m */,
|
||||
FADC44A9176EA82000B2D5ED /* Frameworks */,
|
||||
FADC44A8176EA82000B2D5ED /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
FADC44A8176EA82000B2D5ED /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FADC44A7176EA82000B2D5ED /* libPluginAdmob.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
FADC44A9176EA82000B2D5ED /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FADC44AA176EA82000B2D5ED /* Foundation.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
FADC44B8176EA84500B2D5ED /* Admob */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FADC44B9176EA84500B2D5ED /* GADAdMobExtras.h */,
|
||||
FADC44BA176EA84500B2D5ED /* GADAdNetworkExtras.h */,
|
||||
FADC44BB176EA84500B2D5ED /* GADAdSize.h */,
|
||||
FADC44BC176EA84500B2D5ED /* GADBannerView.h */,
|
||||
FADC44BD176EA84500B2D5ED /* GADBannerViewDelegate.h */,
|
||||
FADC44BE176EA84500B2D5ED /* GADInterstitial.h */,
|
||||
FADC44BF176EA84500B2D5ED /* GADInterstitialDelegate.h */,
|
||||
FADC44C0176EA84500B2D5ED /* GADRequest.h */,
|
||||
FADC44C1176EA84500B2D5ED /* GADRequestError.h */,
|
||||
FADC44C2176EA84500B2D5ED /* libGoogleAdMobAds.a */,
|
||||
);
|
||||
path = Admob;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
FADC44A6176EA82000B2D5ED /* PluginAdmob */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = FADC44B5176EA82000B2D5ED /* Build configuration list for PBXNativeTarget "PluginAdmob" */;
|
||||
buildPhases = (
|
||||
FADC44A3176EA82000B2D5ED /* Sources */,
|
||||
FADC44A4176EA82000B2D5ED /* Frameworks */,
|
||||
FADC44A5176EA82000B2D5ED /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = PluginAdmob;
|
||||
productName = PluginAdmob;
|
||||
productReference = FADC44A7176EA82000B2D5ED /* libPluginAdmob.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
FADC449F176EA82000B2D5ED /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0460;
|
||||
ORGANIZATIONNAME = "cocos2d-x";
|
||||
};
|
||||
buildConfigurationList = FADC44A2176EA82000B2D5ED /* Build configuration list for PBXProject "PluginAdmob" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = FADC449E176EA82000B2D5ED;
|
||||
productRefGroup = FADC44A8176EA82000B2D5ED /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
FADC44A6176EA82000B2D5ED /* PluginAdmob */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
FADC44A3176EA82000B2D5ED /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
FADC44C6176EA84500B2D5ED /* AdsAdmob.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
FADC44B3176EA82000B2D5ED /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
FADC44B4176EA82000B2D5ED /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
FADC44B6176EA82000B2D5ED /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
DSTROOT = /tmp/PluginAdmob.dst;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "PluginAdmob-Prefix.pch";
|
||||
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/Admob\"",
|
||||
);
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
FADC44B7176EA82000B2D5ED /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
DSTROOT = /tmp/PluginAdmob.dst;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "PluginAdmob-Prefix.pch";
|
||||
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/Admob\"",
|
||||
);
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
FADC44A2176EA82000B2D5ED /* Build configuration list for PBXProject "PluginAdmob" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
FADC44B3176EA82000B2D5ED /* Debug */,
|
||||
FADC44B4176EA82000B2D5ED /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
FADC44B5176EA82000B2D5ED /* Build configuration list for PBXNativeTarget "PluginAdmob" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
FADC44B6176EA82000B2D5ED /* Debug */,
|
||||
FADC44B7176EA82000B2D5ED /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = FADC449F176EA82000B2D5ED /* Project object */;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d+x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
typedef enum {
|
||||
kAdsReceived = 0,
|
||||
|
||||
kFullScreenViewShown,
|
||||
kFullScreenViewDismissed,
|
||||
|
||||
kPointsSpendSucceed,
|
||||
kPointsSpendFailed,
|
||||
|
||||
kNetworkError,
|
||||
kUnknownError,
|
||||
} AdsResult;
|
||||
|
||||
typedef enum {
|
||||
kTypeBanner = 0,
|
||||
kTypeFullScreen,
|
||||
} AdsTypeEnum;
|
||||
|
||||
typedef enum {
|
||||
kPosCenter = 0,
|
||||
kPosTop,
|
||||
kPosTopLeft,
|
||||
kPosTopRight,
|
||||
kPosBottom,
|
||||
kPosBottomLeft,
|
||||
kPosBottomRight,
|
||||
} AdsPosEnum;
|
||||
|
||||
@interface AdsWrapper : NSObject
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
+ (void) onAdsResult:(id) obj withRet:(AdsResult) ret withMsg:(NSString*) msg;
|
||||
+ (void) addAdView:(UIView*) view atPos:(AdsPosEnum) pos;
|
||||
+ (UIViewController *) getCurrentRootViewController;
|
||||
|
||||
@end
|
|
@ -0,0 +1,133 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d+x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import "AdsWrapper.h"
|
||||
#include "PluginUtilsIOS.h"
|
||||
#include "ProtocolAds.h"
|
||||
|
||||
using namespace cocos2d::plugin;
|
||||
|
||||
@implementation AdsWrapper
|
||||
|
||||
+ (void) onAdsResult:(id) obj withRet:(AdsResult) ret withMsg:(NSString*) msg
|
||||
{
|
||||
PluginProtocol* pPlugin = PluginUtilsIOS::getPluginPtr(obj);
|
||||
ProtocolAds* pAds = dynamic_cast<ProtocolAds*>(pPlugin);
|
||||
if (pAds) {
|
||||
const char* chMsg = [msg UTF8String];
|
||||
AdsResultCode cRet = (AdsResultCode) ret;
|
||||
pAds->onAdsResult(cRet, chMsg);
|
||||
} else {
|
||||
PluginUtilsIOS::outputLog("Can't find the C++ object of the ads plugin");
|
||||
}
|
||||
}
|
||||
|
||||
+ (void) addAdView:(UIView*) view atPos:(AdsPosEnum) pos
|
||||
{
|
||||
UIViewController* controller = [AdsWrapper getCurrentRootViewController];
|
||||
|
||||
if (nil == controller) {
|
||||
PluginUtilsIOS::outputLog("Can't get the UIViewController object");
|
||||
return;
|
||||
}
|
||||
|
||||
CGSize rootSize = controller.view.frame.size;
|
||||
CGSize viewSize = view.frame.size;
|
||||
CGPoint viewOrigin;
|
||||
|
||||
if (UIInterfaceOrientationIsLandscape(controller.interfaceOrientation)){
|
||||
CGFloat temp = rootSize.width;
|
||||
rootSize.width = rootSize.height;
|
||||
rootSize.height = temp;
|
||||
}
|
||||
|
||||
switch (pos) {
|
||||
case kPosTop:
|
||||
viewOrigin.x = (rootSize.width - viewSize.width) / 2;
|
||||
viewOrigin.y = 0.0f;
|
||||
break;
|
||||
case kPosTopLeft:
|
||||
viewOrigin.x = 0.0f;
|
||||
viewOrigin.y = 0.0f;
|
||||
break;
|
||||
case kPosTopRight:
|
||||
viewOrigin.x = rootSize.width - viewSize.width;
|
||||
viewOrigin.y = 0.0f;
|
||||
break;
|
||||
case kPosBottom:
|
||||
viewOrigin.x = (rootSize.width - viewSize.width) / 2;
|
||||
viewOrigin.y = rootSize.height - viewSize.height;
|
||||
break;
|
||||
case kPosBottomLeft:
|
||||
viewOrigin.x = 0.0f;
|
||||
viewOrigin.y = rootSize.height - viewSize.height;
|
||||
break;
|
||||
case kPosBottomRight:
|
||||
viewOrigin.x = rootSize.width - viewSize.width;
|
||||
viewOrigin.y = rootSize.height - viewSize.height;
|
||||
break;
|
||||
case kPosCenter:
|
||||
default:
|
||||
viewOrigin.x = (rootSize.width - viewSize.width) / 2;
|
||||
viewOrigin.y = (rootSize.height - viewSize.height) / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
CGRect rect = CGRectMake(viewOrigin.x, viewOrigin.y, viewSize.width, viewSize.height);
|
||||
view.frame = rect;
|
||||
[controller.view addSubview:view];
|
||||
}
|
||||
|
||||
+ (UIViewController *)getCurrentRootViewController {
|
||||
|
||||
UIViewController *result = nil;
|
||||
|
||||
// Try to find the root view controller programmically
|
||||
|
||||
// Find the top window (that is not an alert view or other window)
|
||||
UIWindow *topWindow = [[UIApplication sharedApplication] keyWindow];
|
||||
if (topWindow.windowLevel != UIWindowLevelNormal)
|
||||
{
|
||||
NSArray *windows = [[UIApplication sharedApplication] windows];
|
||||
for(topWindow in windows)
|
||||
{
|
||||
if (topWindow.windowLevel == UIWindowLevelNormal)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UIView *rootView = [[topWindow subviews] objectAtIndex:0];
|
||||
id nextResponder = [rootView nextResponder];
|
||||
|
||||
if ([nextResponder isKindOfClass:[UIViewController class]])
|
||||
result = nextResponder;
|
||||
else if ([topWindow respondsToSelector:@selector(rootViewController)] && topWindow.rootViewController != nil)
|
||||
result = topWindow.rootViewController;
|
||||
else
|
||||
NSAssert(NO, @"Could not find a root view controller.");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
|
@ -18,6 +18,7 @@
|
|||
FAB6DF981755D82F00C90D89 /* PluginFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DF971755D82F00C90D89 /* PluginFactory.mm */; };
|
||||
FAB6DF9A1755D93600C90D89 /* PluginProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DF991755D93600C90D89 /* PluginProtocol.mm */; };
|
||||
FAB6DFD31756EA4D00C90D89 /* ProtocolSocial.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DFD21756EA4D00C90D89 /* ProtocolSocial.mm */; };
|
||||
FADC44CA176EABCF00B2D5ED /* AdsWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */; };
|
||||
FAE27553175DB9FB00F5DA8E /* SocialWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAE27552175DB9FB00F5DA8E /* SocialWrapper.mm */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
@ -60,6 +61,8 @@
|
|||
FAB6DF991755D93600C90D89 /* PluginProtocol.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginProtocol.mm; sourceTree = "<group>"; };
|
||||
FAB6DFCD1755EF8E00C90D89 /* PluginOCMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginOCMacros.h; sourceTree = "<group>"; };
|
||||
FAB6DFD21756EA4D00C90D89 /* ProtocolSocial.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolSocial.mm; sourceTree = "<group>"; };
|
||||
FADC44C8176EABCF00B2D5ED /* AdsWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdsWrapper.h; sourceTree = "<group>"; };
|
||||
FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AdsWrapper.mm; sourceTree = "<group>"; };
|
||||
FAE27551175DB9FB00F5DA8E /* SocialWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialWrapper.h; sourceTree = "<group>"; };
|
||||
FAE27552175DB9FB00F5DA8E /* SocialWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SocialWrapper.mm; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
@ -125,6 +128,8 @@
|
|||
FA0CB8B5168D3CC200E36B11 /* ios */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FADC44C8176EABCF00B2D5ED /* AdsWrapper.h */,
|
||||
FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */,
|
||||
FAE27551175DB9FB00F5DA8E /* SocialWrapper.h */,
|
||||
FAE27552175DB9FB00F5DA8E /* SocialWrapper.mm */,
|
||||
FAB6DFCD1755EF8E00C90D89 /* PluginOCMacros.h */,
|
||||
|
@ -206,6 +211,7 @@
|
|||
FAB6DF9A1755D93600C90D89 /* PluginProtocol.mm in Sources */,
|
||||
FAB6DFD31756EA4D00C90D89 /* ProtocolSocial.mm in Sources */,
|
||||
FAE27553175DB9FB00F5DA8E /* SocialWrapper.mm in Sources */,
|
||||
FADC44CA176EABCF00B2D5ED /* AdsWrapper.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue