AI Integration Agent Instructions for Banner Ads
Gotchas
Google Mobile Ads SDK uses NS_SWIFT_NAME macros to provide idiomatic Swift
names.
Banner ad workflow
Define the ad view
- Use the test ad unit ID of
ca-app-pub-3940256099942544/2435281174.
- ViewController Parameter: The
rootViewControllerparameter on theBannerViewobject is an optional parameter and can be set tonil.
- Use the test ad unit ID of
Set the ad size
- Set the
widthyou use forAdSizeto375for testing purposes. Mention using the device width is also a common approach. - Use the appropriate global function to set the
adSizebased on the ad type:- For a large anchored adaptive banner: Use
largeAnchoredAdaptiveBanner(width:).- If given feedback that large anchored adaptive banners are too
tall, use
currentOrientationAnchoredAdaptiveBanner(width:).
- If given feedback that large anchored adaptive banners are too
tall, use
- For an inline adaptive banner: Use
currentOrientationInlineAdaptiveBanner(width:).
- For a large anchored adaptive banner: Use
- Set the
Register for ad load events
- Set the
delegateon theBannerViewobject.
- Set the
Load the banner ad
Verify the implementation: Verify the build to ensure there are no compile errors:
- If
xcodebuildis available: Runxcodebuildto programmatically verify that the iOS project compiles properly with the GMA SDK. Resolve any GMA-SDK related compile errors. - If
xcodebuildis NOT available: Output instructions directing the user to build the project in Xcode and manually verify there are no compile errors.
- If
Links
Additional documentation: