GADBannerView.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // GADBannerView.h
  3. // Google Mobile 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 "GADRequest.h"
  12. #import "GADRequestError.h"
  13. #import "GoogleMobileAdsDefines.h"
  14. #ifndef IBInspectable
  15. #define IBInspectable
  16. #endif
  17. /// The view that displays banner ads. A minimum implementation to get an ad from within a
  18. /// UIViewController class is:
  19. ///
  20. /// \code
  21. /// // Create and setup the ad view, specifying the size and origin at {0, 0}.
  22. /// GADBannerView *adView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
  23. /// adView.rootViewController = self;
  24. /// adView.adUnitID = @"ID created when registering your app";
  25. ///
  26. /// // Place the ad view onto the screen.
  27. /// [self.view addSubview:adView];
  28. ///
  29. /// // Request an ad without any additional targeting information.
  30. /// [adView loadRequest:[GADRequest request]];
  31. /// \endcode
  32. ///
  33. @interface GADBannerView : UIView
  34. #pragma mark Initialization
  35. /// Initializes a GADBannerView and sets it to the specified size, and specifies its placement
  36. /// within its superview bounds. Returns nil if |adSize| is an invalid ad size.
  37. - (instancetype)initWithAdSize:(GADAdSize)adSize origin:(CGPoint)origin;
  38. /// Initializes a GADBannerView and sets it to the specified size, and specifies its placement at
  39. /// the top left of its superview. Returns nil if |adSize| is an invalid ad size.
  40. - (instancetype)initWithAdSize:(GADAdSize)adSize;
  41. #pragma mark Pre-Request
  42. /// Required value created on the AdMob website. Create a new ad unit for every unique placement of
  43. /// an ad in your application. Set this to the ID assigned for this placement. Ad units are
  44. /// important for targeting and statistics.
  45. ///
  46. /// Example AdMob ad unit ID: @"ca-app-pub-0123456789012345/0123456789"
  47. @property(nonatomic, copy) IBInspectable NSString *adUnitID;
  48. /// Required reference to the current root view controller. For example the root view controller in
  49. /// tab-based application would be the UITabViewController.
  50. @property(nonatomic, weak) IBOutlet UIViewController *rootViewController;
  51. /// Required to set this banner view to a proper size. Never create your own GADAdSize directly. Use
  52. /// one of the predefined standard ad sizes (such as kGADAdSizeBanner), or create one using the
  53. /// GADAdSizeFromCGSize method. If not using mediation, then changing the adSize after an ad has
  54. /// been shown will cause a new request (for an ad of the new size) to be sent. If using mediation,
  55. /// then a new request may not be sent.
  56. @property(nonatomic, assign) GADAdSize adSize;
  57. /// Optional delegate object that receives state change notifications from this GADBannerView.
  58. /// Typically this is a UIViewController.
  59. @property(nonatomic, weak) IBOutlet id<GADBannerViewDelegate> delegate;
  60. /// Optional delegate object that receives in-app purchase notifications from this ad. Required for
  61. /// the custom in-app purchase flow, but ignored when using the default in-app purchase flow.
  62. @property(nonatomic, weak) IBOutlet id<GADInAppPurchaseDelegate> inAppPurchaseDelegate;
  63. #pragma mark Making an Ad Request
  64. /// Makes an ad request. The request object supplies targeting information.
  65. - (void)loadRequest:(GADRequest *)request;
  66. /// A Boolean value that determines whether autoloading of ads in the receiver is enabled. If
  67. /// enabled, you do not need to call the loadRequest: method to load ads.
  68. @property(nonatomic, assign, getter=isAutoloadEnabled) IBInspectable BOOL autoloadEnabled;
  69. #pragma mark Mediation
  70. /// The ad network class name that fetched the current ad. Returns nil while the latest ad request
  71. /// is in progress or if the latest ad request failed. For both standard and mediated Google AdMob
  72. /// ads, this method returns @"GADMAdapterGoogleAdMobAds". For ads fetched via mediation custom
  73. /// events, this method returns @"GADMAdapterCustomEvents".
  74. @property(nonatomic, readonly, copy) NSString *adNetworkClassName;
  75. #pragma mark Deprecated
  76. /// Indicates if the currently displayed ad (or most recent failure) was a result of auto refreshing
  77. /// as specified on server. This property is set to NO after each loadRequest: method.
  78. @property(nonatomic, readonly, assign) BOOL hasAutoRefreshed GAD_DEPRECATED_ATTRIBUTE;
  79. /// The mediated ad network's underlying ad view. You may use this property to read the ad's actual
  80. /// size and adjust this banner view's frame origin. However, modifying the banner view's frame size
  81. /// triggers the Mobile Ads SDK to request a new ad. Only update the banner view's frame origin.
  82. @property(nonatomic, readonly, weak)
  83. UIView *mediatedAdView GAD_DEPRECATED_MSG_ATTRIBUTE("Use adNetworkClassName.");
  84. @end