AI-generated Key Takeaways
-
GAMBannerView is a view class for displaying Ad Manager banner ads.
-
The
adUnitIDis a required value from the Ad Manager website used to identify a unique ad placement. -
Optional delegates like
appEventDelegateandadSizeDelegatecan be used to receive notifications about ad events and size changes. -
The
validAdSizesproperty allows specifying an array of valid ad sizes for the banner view. -
Manual impression recording can be enabled using
enableManualImpressionsand recorded with therecordImpressionmethod.
GAMBannerView
@interface GAMBannerView : GADBannerViewThe view that displays Ad Manager banner ads.
To request this ad type using GADAdLoader, you need to pass GADAdLoaderAdTypeGAMBanner (see GADAdLoaderAdTypes.h) to the |adTypes| parameter in GADAdLoader’s initializer method. If you request this ad type, your delegate must conform to the GAMBannerAdLoaderDelegate protocol.
-
Required value created on the Ad Manager 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 statistics.
Example Ad Manager ad unit ID: @“/6499/example/banner”
Declaration
Swift
var adUnitID: String? { get set }Objective-C
@property (nonatomic, copy, nullable) NSString *adUnitID; -
Optional delegate that is notified when creatives send app events.
Declaration
Swift
@IBOutlet weak var appEventDelegate: (any AppEventDelegate)? { get set }Objective-C
@property (nonatomic, weak, nullable) id<GADAppEventDelegate> appEventDelegate; -
Optional delegate that is notified when creatives cause the banner to change size.
Declaration
Swift
@IBOutlet weak var adSizeDelegate: (any AdSizeDelegate)? { get set }Objective-C
@property (nonatomic, weak, nullable) id<GADAdSizeDelegate> adSizeDelegate; -
Optional array of NSValue encoded GADAdSize structs, specifying all valid sizes that are appropriate for this slot. Never create your own GADAdSize directly. Use one of the predefined standard ad sizes (such as GADAdSizeBanner), or create one using the GADAdSizeFromCGSize method.
Example:
\code NSArray *validSizes = @[ NSValueFromGADAdSize(GADAdSizeBanner), NSValueFromGADAdSize(GADAdSizeLargeBanner) ];
bannerView.validAdSizes = validSizes; \endcode
Declaration
Swift
var validAdSizes: [NSValue]? { get set }Objective-C
@property (nonatomic, copy, nullable) NSArray<NSValue *> *validAdSizes; -
Indicates that the publisher will record impressions manually when the ad becomes visible to the user.
Declaration
Swift
var enableManualImpressions: Bool { get set }Objective-C
@property (nonatomic) BOOL enableManualImpressions; -
Video controller for controlling video rendered by this ad view.
Declaration
Swift
var videoController: VideoController { get }Objective-C
@property (nonatomic, readonly, nonnull) GADVideoController *videoController; -
If you’ve set manualImpressionsEnabled to YES, call this method when the ad is visible.
Declaration
Swift
func recordImpression()Objective-C
- (void)recordImpression; -
Use this function to resize the banner view without launching a new ad request.
-
Sets options that configure ad loading.
Declaration
Swift
func setAdOptions(_ adOptions: [GADAdLoaderOptions])Objective-C
- (void)setAdOptions:(nonnull NSArray<GADAdLoaderOptions *> *)adOptions;Parameters
adOptionsAn array of GADAdLoaderOptions objects. The array is deep copied and option objects cannot be modified after calling this method.