Documentation

Unity Ads Monetization


iOS API reference - Swift

iOS API reference - Objective-C

Unity Ads Monetization


Implement banner ads in iOS

Implement banner ads in your iOS app. Create and display banner view objects within your view hierarchy, and use a delegate to manage ad events.
Read time 1 minuteLast updated a day ago

Important
app-ads.txt is an IAB initiative to combat fraud and create transparency in the advertising ecosystem. Ensure that you implement app-ads.txt as described. Otherwise, banner demand might significantly decrease.
You can place the banner view object into your view hierarchy, just like you would any other view. This allows you to customize the position of each banner instance, or display multiple banners.
Note
Banner content will not render outside of the Safe Area, as described in Apple's guidelines.

Script implementation

The following script sample is an example implementation for displaying two banner ads on the screen. For more information on the classes referenced, refer to the
UADSBannerAd
API section.

Implementing the MREC banner format

Note
You must initialize Unity Ads before displaying a banner ad.
To display a medium rectangle (MREC) sized ad format in your app, ensure the proper dimensions are used, such as 300x250, 300x300, or 450x450. In the case of a 300x250 MREC banner ad specifically, replace this in the following example code:
CGSizeMake(320, 50)
With this adjusted dimension:
CGSizeMake(300, 250)
@interface MyDelegate : NSObject <UADSBannerAdDelegate>@end@implementation MyDelegate- (void)bannerImpression:(UADSBannerAd *)banner {}- (void)bannerDidClick:(UADSBannerAd *)banner {}- (void)bannerDidFailShow:(UADSBannerAd *)banner error:(id<UnityAdsError>)error {}@end@property (strong) UADSBannerAd *bannerAd;UADSBannerLoadConfigurationBuilder *builder =[[UADSBannerLoadConfigurationBuilder alloc]initWithPlacementId:placementId bannerSize:CGSizeMake(320, 50) delegate:delegate];builder = [builder withMediationInfo:self.mediationInfo];builder = [builder withAdMarkup:bidResponse];[UADSBannerAd load:[builder build] completion:^(UADSBannerAd *ad, id<UnityAdsError> error) {if (!error) { self.bannerAd = ad; [container addSubview:ad.view];}}];
Next steps: Review the monetization strategy guide and test your implementation.