GoogleMobileAds Framework Reference
Functions
The following functions are available globally.
-
Returns a GADAdSize with the given width and the device’s portrait height. This ad size
allows Google servers to choose an optimal ad size less than or equal to the returned size. The
exact size of the ad returned is passed through the banner’s ad size delegate and is indicated
by the banner’s intrinsicContentSize. This ad size is most suitable for ads intended for scroll
views.
Declaration
Swift
func GADPortraitInlineAdaptiveBannerAdSizeWithWidth(_ width: CGFloat) -> GADAdSize
Objective-C
extern GADAdSize GADPortraitInlineAdaptiveBannerAdSizeWithWidth(CGFloat width)
-
Returns a GADAdSize with the given width and the device’s landscape height. This ad size
allows Google servers to choose an optimal ad size less than or equal to the returned size. The
exact size of the ad returned is passed through the banner’s ad size delegate and is indicated
by the banner’s intrinsicContentSize. This ad size is most suitable for ads intended for scroll
views.
Declaration
Swift
func GADLandscapeInlineAdaptiveBannerAdSizeWithWidth(_ width: CGFloat) -> GADAdSize
Objective-C
extern GADAdSize GADLandscapeInlineAdaptiveBannerAdSizeWithWidth(CGFloat width)
-
Returns a GADAdSize with the given width and the device’s height. This is a convenience
function to return GADPortraitInlineAdaptiveBannerAdSizeWithWidth or
GADLandscapeInlineAdaptiveBannerAdSizeWithWidth based on the current interface orientation.
This function must be called on the main queue.
Declaration
Swift
func GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(_ width: CGFloat) -> GADAdSize
Objective-C
extern GADAdSize
GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(CGFloat width)
-
Returns a GADAdSize with the given width and max height. This ad size allows Google servers to
choose an optimal ad size less than or equal to the returned size. The exact size of the ad
returned is passed through the banner’s ad size delegate and is indicated by the banner’s
intrinsicContentSize. This ad size is most suitable for ads intended for scroll views.
Declaration
Swift
func GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(_ width: CGFloat, _ maxHeight: CGFloat) -> GADAdSize
Objective-C
extern GADAdSize
GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(CGFloat width,
CGFloat maxHeight)
Parameters
width
|
|
maxHeight
|
The maximum height a loaded ad will have. Must be at least 32 px, but a max
height of 50 px or higher is recommended.
|
-
Returns a GADAdSize with the given width and a Google-optimized height to create a banner ad.
The size returned has an aspect ratio similar to that of GADAdSizeBanner, suitable for
anchoring near the top or bottom of your app. The height is never larger than 15% of the
device’s portrait height and is always between 50-90 points. This function always returns the
same height for any width / device combination.
Declaration
Swift
func GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(_ width: CGFloat) -> GADAdSize
Objective-C
extern GADAdSize GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width)
-
Returns a GADAdSize with the given width and a Google-optimized height to create a banner ad.
The size returned is suitable for use in a banner ad anchored near the top or bottom of your
app, similar to use of GADAdSizeBanner. The height is never larger than 15% of the devices’s
landscape height and is always between 50-90 points. This function always returns the same
height for any width / device combination.
Declaration
Swift
func GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(_ width: CGFloat) -> GADAdSize
Objective-C
extern GADAdSize
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width)
-
Returns a GADAdSize with the given width and a Google-optimized height. This is a convenience
function to return GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth or
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth based on the current interface orientation.
This function must be called on the main queue.
Declaration
Swift
func GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(_ width: CGFloat) -> GADAdSize
Objective-C
extern GADAdSize
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width)
-
Returns a custom GADAdSize for the provided CGSize. Use this only if you require a non-standard
size. Otherwise, use one of the standard size constants above.
Declaration
Swift
func GADAdSizeFromCGSize(_ size: CGSize) -> GADAdSize
Objective-C
extern GADAdSize GADAdSizeFromCGSize(CGSize size)
-
Returns a custom GADAdSize that spans the full width of the application in portrait orientation
with the height provided.
Declaration
Swift
func GADAdSizeFullWidthPortraitWithHeight(_ height: CGFloat) -> GADAdSize
Objective-C
extern GADAdSize GADAdSizeFullWidthPortraitWithHeight(CGFloat height)
-
Returns a custom GADAdSize that spans the full width of the application in landscape orientation
with the height provided.
Declaration
Swift
func GADAdSizeFullWidthLandscapeWithHeight(_ height: CGFloat) -> GADAdSize
Objective-C
extern GADAdSize GADAdSizeFullWidthLandscapeWithHeight(CGFloat height)
-
Returns YES if the two GADAdSizes are equal, otherwise returns NO.
-
Returns a CGSize for the provided a GADAdSize constant. If the GADAdSize is unknown, returns
CGSizeZero.
Declaration
Swift
func CGSizeFromGADAdSize(_ size: GADAdSize) -> CGSize
Objective-C
extern CGSize CGSizeFromGADAdSize(GADAdSize size)
-
Returns YES if |size| is one of the predefined constants or is a custom GADAdSize generated by
GADAdSizeFromCGSize.
Declaration
Swift
func IsGADAdSizeValid(_ size: GADAdSize) -> Bool
Objective-C
extern BOOL IsGADAdSizeValid(GADAdSize size)
-
Returns YES if |size| is a fluid ad size.
Declaration
Swift
func GADAdSizeIsFluid(_ size: GADAdSize) -> Bool
Objective-C
extern BOOL GADAdSizeIsFluid(GADAdSize size)
-
Returns a NSString describing the provided GADAdSize.
Declaration
Swift
func NSStringFromGADAdSize(_ size: GADAdSize) -> String
Objective-C
extern NSString *_Nonnull NSStringFromGADAdSize(GADAdSize size)
-
Returns an NSValue representing the GADAdSize.
Declaration
Swift
func NSValueFromGADAdSize(_ size: GADAdSize) -> NSValue
Objective-C
extern NSValue *_Nonnull NSValueFromGADAdSize(GADAdSize size)
-
Returns a GADAdSize from an NSValue. Returns GADAdSizeInvalid if the value is not a GADAdSize.
Declaration
Swift
func GADAdSizeFromNSValue(_ value: NSValue) -> GADAdSize
Objective-C
extern GADAdSize GADAdSizeFromNSValue(NSValue *_Nonnull value)
-
Returns the closest valid ad size from possibleAdSizes as compared to |original|. The selected
size must be smaller than or equal in size to the original. The selected size must also be
within a configurable fraction of the width and height of the original. If no valid size exists,
returns GADAdSizeInvalid.
Declaration
Swift
func GADClosestValidSizeForAdSizes(_ original: GADAdSize, _ possibleAdSizes: [NSValue]) -> GADAdSize
Objective-C
extern GADAdSize
GADClosestValidSizeForAdSizes(GADAdSize original,
NSArray<NSValue *> *_Nonnull possibleAdSizes)
-
Returns a string representation of the version number.
Declaration
Objective-C
NSString *_Nonnull GADGetStringFromVersionNumber(GADVersionNumber version)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-06-26 UTC.
[null,null,["Last updated 2023-06-26 UTC."],[[["This document outlines the available functions for defining and managing ad sizes within the Google Mobile Ads SDK."],["It categorizes functions into Inline Adaptive, Anchored Adaptive, Custom, and Convenience groups for easier navigation."],["Each function is described with its purpose, declaration in Swift and Objective-C, and any relevant parameters."],["The functions provide ways to create standard, adaptive, custom, and fluid ad sizes, and to perform operations like size comparisons and conversions."],["Developers can use these functions to request ads of specific dimensions, handle size adjustments, and ensure ad display compatibility within their applications."]]],[]]