GADBannerView.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // GADBannerView.h
  3. // Google AdMob Ads SDK
  4. //
  5. // Copyright 2011 Google Inc. All rights reserved.
  6. //
  7. #import <UIKit/UIKit.h>
  8. #import "GADAdSize.h"
  9. #import "GADBannerViewDelegate.h"
  10. #import "GADInAppPurchaseDelegate.h"
  11. #import "GADModules.h"
  12. #import "GADRequest.h"
  13. #import "GADRequestError.h"
  14. /// The view that displays banner ads. A minimum implementation to get an ad
  15. /// from within a UIViewController class is:
  16. ///
  17. /// \code
  18. /// // Create and setup the ad view, specifying the size and origin at {0, 0}.
  19. /// GADBannerView *adView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
  20. /// adView.rootViewController = self;
  21. /// adView.adUnitID = @"ID created when registering my app";
  22. ///
  23. /// // Place the ad view onto the screen.
  24. /// [self.view addSubview:adView];
  25. /// [adView release];
  26. ///
  27. /// // Request an ad without any additional targeting information.
  28. /// [adView loadRequest:nil];
  29. /// \endcode
  30. ///
  31. @interface GADBannerView : UIView
  32. #pragma mark Initialization
  33. /// Initializes a GADBannerView and sets it to the specified size, and specifies its placement
  34. /// within its superview bounds. If |size| is invalid, an instance of GADBannerView is not created
  35. /// and nil is returned instead.
  36. - (id)initWithAdSize:(GADAdSize)size origin:(CGPoint)origin;
  37. /// Initializes a GADBannerView and sets it to the specified size, and specifies its placement at
  38. /// the top left of its superview. If |size| is invalid, an instance of GADBannerView is not created
  39. /// and nil is returned instead.
  40. - (id)initWithAdSize:(GADAdSize)size;
  41. #pragma mark Pre-Request
  42. /// Required value created in the AdSense website. Create a new ad unit for every unique placement
  43. /// of an ad in your application. Set this to the ID assigned for this placement. Ad units are
  44. /// important for targeting and stats.
  45. /// Example values for different request types:
  46. ///
  47. /// AdMob: a0123456789ABCD
  48. /// DFP: /0123/ca-pub-0123456789012345/my-ad-identifier
  49. /// AdSense: ca-mb-app-pub-0123456789012345/my-ad-identifier
  50. /// Mediation: AB123456789ABCDE
  51. @property(nonatomic, copy) NSString *adUnitID;
  52. /// Required reference to the current root view controller. For example the root view controller in
  53. /// tab-based application would be the UITabViewController.
  54. @property(nonatomic, weak) UIViewController *rootViewController;
  55. /// Required to set this banner view to a proper size. Never create your own GADAdSize directly. Use
  56. /// one of the predefined standard ad sizes (such as kGADAdSizeBanner), or create one using the
  57. /// GADAdSizeFromCGSize method. If not using mediation, then changing the adSize after an ad has
  58. /// been shown will cause a new request (for an ad of the new size) to be sent. If using mediation,
  59. /// then a new request may not be sent.
  60. @property(nonatomic, assign) GADAdSize adSize;
  61. /// Optional delegate object that receives state change notifications from this GADBannerView.
  62. /// Typically this is a UIViewController, however, if you are unfamiliar with the delegate pattern
  63. /// it is recommended you subclass this GADBannerView and make it the delegate. That avoids any
  64. /// chance of your application crashing if you forget to nil out the delegate. For example:
  65. ///
  66. /// \code
  67. /// @interface MyAdView : GADBannerView <GADBannerViewDelegate>
  68. /// @end
  69. ///
  70. /// @implementation MyAdView
  71. /// - (id)initWithFrame:(CGRect)frame {
  72. /// self = [super initWithFrame:frame];
  73. /// if (self) {
  74. /// self.delegate = self;
  75. /// }
  76. /// return self;
  77. /// }
  78. ///
  79. /// - (void)dealloc {
  80. /// self.delegate = nil;
  81. /// [super dealloc];
  82. /// }
  83. ///
  84. /// @end
  85. /// \endcode
  86. @property(nonatomic, weak) NSObject<GADBannerViewDelegate> *delegate;
  87. /// Optional delegate object that receives In-App Purchase (IAP) notifications from this
  88. /// GADBannerView. Remember to nil the delegate before deallocating this object.
  89. @property(nonatomic, weak) id<GADInAppPurchaseDelegate> inAppPurchaseDelegate;
  90. #pragma mark Making an Ad Request
  91. /// Makes an ad request. Additional targeting options can be supplied with a request object. Refresh
  92. /// the ad by calling this method again.
  93. - (void)loadRequest:(GADRequest *)request;
  94. #pragma mark Ad Request
  95. /// Indicates if the currently displayed ad (or most recent failure) was a result of auto refreshing
  96. /// as specified on server. This property is set to NO after each loadRequest: method.
  97. @property(nonatomic, readonly, assign) BOOL hasAutoRefreshed;
  98. #pragma mark Mediation
  99. /// The underlying ad view of the mediated ad network. You may use this to find out the actual
  100. /// size of the ad and adjust GADBannerView to fit the underlying ad view.
  101. @property(nonatomic, readonly, weak) UIView *mediatedAdView;
  102. /// The ad network class name that fetched the current ad. Returns nil while the latest ad request
  103. /// is in progress or if the latest ad request failed. For both standard and mediated Google AdMob
  104. /// ads, this method returns @"GADMAdapterGoogleAdMobAds". For ads fetched via mediation custom
  105. /// events, this method returns @"GADMAdapterCustomEvents".
  106. @property(nonatomic, readonly, weak) NSString *adNetworkClassName;
  107. @end