# Unity Ads iOS SDK API reference - Objective-C

> Access the Unity Ads SDK public API reference to view available classes, methods, and properties you can use in Objective-C to integrate and control ad behavior in your iOS app.

Use this reference for the Unity Ads iOS SDK API in Objective-C as you integrate Unity Ads into your iOS applications.

Before using this API, ensure that you've imported the `UnityAds` library to enable monetization in your app. Refer to [Import the UnityAds library](/ads-ios/4.19.0/sdk-integration/import-library.md) for more information.

## Classes

## UADSBannerAd

The `UADSBannerAd` class manages the loading and showing of banner ads.

### load:completion:\_

1. **Objective-C**

   ```objective-c
   @interface UADSBannerAd : NSObject
   + (void)load:(UADSBannerLoadConfiguration * _Nonnull)config
     completion:(void (^ _Nonnull)(UADSBannerAd * _Nullable, id<UnityAdsError> _Nullable))completion;
   @end
   ```

Loads a banner ad with the specified configuration.

| **Parameters** | **Description**                                                                                                                                  |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| configuration  | The options for loading the banner ad.                                                                                                           |
| completion     | A callback that gets called when the banner is loaded. Returns the loaded BannerAd instance if successful, or an UnityAdsError if loading fails. |

### view

1. **Objective-C**

   ```objective-c
   @interface UADSBannerAd : NSObject
   @property (nonatomic, readonly, strong) UIView * _Nonnull view;
   @end
   ```

A view property that provides access to the banner ad instance. Use this property to insert the banner ad within your app's existing view hierarchy at the desired location.

### UADSBannerView

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use [`UADSBannerAd`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsbannerad) instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UADSBannerView` was the previous class for loading and displaying banner ads.

### UADSBannerViewDelegate

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use [`UADSBannerAdDelegate`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsbanneraddelegate) instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UADSBannerViewDelegate` was the previous delegate protocol for handling banner ad events.

## UADSBannerLoadConfiguration

The `UADSBannerLoadConfiguration` class encapsulates the options needed to load banner ads. This includes specifying the placement ID, banner size, optional ad markup, optional delegate, and any additional parameters.

1. **Objective-C**

   ```objective-c
   @interface BannerLoadConfiguration : NSObject
   @property (nonatomic, strong) NSString *placementId;
   @property (nonatomic, strong, nullable) NSString *adMarkup;
   @property (nonatomic, assign) CGSize bannerSize;
   @property (nonatomic, weak, nullable) id<UADSBannerAdDelegate> delegate;
   @property (nonatomic, strong, nullable) NSString *mediationAdUnitId;
   @property (nonatomic, strong, nullable) MediationInfo *mediationInfo;
   @property (nonatomic, strong) NSDictionary<NSString *, NSString *> *extras;
   @end
   ```

| **Property**        | **Description**                                                            | **Required** |
| ------------------- | -------------------------------------------------------------------------- | ------------ |
| `placementId`       | The placement ID defined in the Unity Monetization Dashboard.              | Yes          |
| `adMarkup`          | Ad markup data that's used when loading an ad through bidding.             | No           |
| `bannerSize`        | The size of the banner ad.                                                 | Yes          |
| `delegate`          | Delegate to handle banner ad events.                                       | Yes          |
| `mediationAdUnitId` | The ad unit or placement ID defined in your mediation partner's dashboard. | No           |
| `mediationInfo`     | Specifies details about your mediation integration.                        | No           |
| `extras`            | Additional custom key–value pairs.                                         | No           |

## UADSBannerLoadConfigurationBuilder

Use `UADSBannerLoadConfigurationBuilder` to create and return an instance of the `UADSBannerLoadConfiguration` class.

### initWithPlacementId:adMarkup:bannerSize:delegate

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)initWithPlacementId:(NSString * _Nonnull)placementId
                                    bannerSize:(CGSize)bannerSize
                                      delegate:(id <UADSBannerAdDelegate> _Nonnull)delegate;
   ```

Creates a new instance of `BannerLoadConfigurationBuilder`.

| **Property**  | **Description**                                               | **Required** |
| ------------- | ------------------------------------------------------------- | ------------ |
| `placementId` | The placement ID defined in the Unity Monetization Dashboard. | Yes          |
| `bannerSize`  | The size of the banner ad.                                    | Yes          |
| `delegate`    | Delegate to handle banner ad events.                          | Yes          |

**Returns**: An instance of `UADSBannerLoadConfigurationBuilder`.

### withAdMarkup:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withAdMarkup:(NSString * _Nonnull)adMarkup
   ```

Adds an adMarkup to the `UADSBannerLoadConfigurationBuilder`.

| **Parameter** | **Description**                                                |
| ------------- | -------------------------------------------------------------- |
| adMarkup      | Ad markup data that's used when loading an ad through bidding. |

### withMediationAdUnitId:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withMediationAdUnitId:(NSString * _Nonnull)mediationAdUnitId
   ```

Adds a mediation ad unit ID to the `UADSBannerLoadConfigurationBuilder`.

| **Parameter**     | **Description**                                                            |
| ----------------- | -------------------------------------------------------------------------- |
| mediationAdUnitId | The ad unit or placement ID defined in your mediation partner's dashboard. |

**Returns**: The updated `UADSBannerLoadConfigurationBuilder` instance.

### withMediationInfo:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withMediationInfo:(UADSMediationInfo * _Nonnull)info
   ```

Adds mediation information to the `UADSBannerLoadConfigurationBuilder`.

| **Parameter** | **Description**                                                           |
| ------------- | ------------------------------------------------------------------------- |
| mediationInfo | Details about the mediation integration (name, version, adapter version). |

**Returns**: The updated UADSBannerLoadConfigurationBuilder instance.

### withExtras:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withExtras:(NSDictionary<NSString *, NSString *> * _Nonnull)extras
   ```

Adds extra key–value parameters to the `UADSBannerLoadConfigurationBuilder`.

| **Parameter** | **Description**                       |
| ------------- | ------------------------------------- |
| extras        | Custom parameters for banner loading. |

**Returns**: The updated `UADSBannerLoadConfigurationBuilder` instance.

### build

1. **Objective-C**

   ```objective-c
   - (UADSBannerLoadConfiguration * _Nonnull)build
   ```

Builds and returns a `UADSBannerLoadConfiguration` instance.

**Returns**: An instance of `UADSBannerLoadConfiguration`.

### UADSBannerLoadOptions

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use [`UADSBannerLoadConfiguration`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsbannerloadconfiguration) and [`UADSBannerLoadConfigurationBuilder`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsbannerloadconfigurationbuilder) instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UADSBannerLoadOptions` was the previous class for specifying banner load options.

## UADSInitializationConfiguration

1. **Objective-C**

   ```objective-c
   @interface UADSInitializationConfiguration: NSObject
   @property (nonatomic, strong) NSString *gameId;
   @property (nonatomic, assign) BOOL isTestModeEnabled;
   @property (nonatomic, assign) UADSLogLevel logLevel;
   @property (nonatomic, strong, nullable) UADSMediationInfo *mediationInfo;
   @property (nonatomic, strong) NSDictionary<NSString *, NSString *> *extras;
   @end
   ```

The `UADSInitializationConfiguration` class creates an object consisting of essential information about your app required to initialize the Unity Ads SDK.

| **Property**        | **Type**                                       | **Description**                                      | **Required** |
| ------------------- | ---------------------------------------------- | ---------------------------------------------------- | ------------ |
| `gameId`            | `NSString *`                                   | Unique identifier for your Unity project.            | Yes          |
| `isTestModeEnabled` | `BOOL`                                         | Enables or disables test mode.                       | No           |
| `logLevel`          | `UADSLogLevel`                                 | Specifies the detail level of log output.            | No           |
| `mediationInfo`     | `UADSMediationInfo * _Nullable`                | Specifies details about your mediation integration.  | No           |
| `extras`            | `NSDictionary&lt;NSString *, NSString *&gt; *` | Additional key–value pairs for custom configuration. | No           |

## UADSInitializationConfigurationBuilder

Use `UADSInitConfigurationBuilder` to create and return an instance of the `UADSInitializationConfiguration` class.

### initWithgameID:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)initWithGameId:(NSString * _Nonnull)gameId
   ```

Creates a new instance of `UADSInitConfigurationBuilder`.

| **Parameter** | **Description**                                                               |
| ------------- | ----------------------------------------------------------------------------- |
| gameId        | Unique identifier for a game, given by Unity Ads admin tools or Unity editor. |

**Returns**: An instance of `UADSInitConfigurationBuilder`.

### withTestMode:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withTestMode:(BOOL)testMode
   ```

Sets the test mode.

| **Parameter** | **Description**                                                       |
| ------------- | --------------------------------------------------------------------- |
| testMode      | Set this flag to `true` to indicate test mode and show only test ads. |

**Returns**: The updated `UADSInitConfigurationBuilder` instance.

### withLogLevel:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withLogLevel:(enum UADSLogLevel)logLevel
   ```

Sets the [log level](#uadsloglevel), which defines the amount of detail included in logs, from none to full debug information.

| **Parameter** | **Description**                           |
| ------------- | ----------------------------------------- |
| level         | Specifies the detail level of log output. |

**Returns**: The updated `UADSInitConfigurationBuilder` instance.

### withMediationInfo:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withMediationInfo:(UADSMediationInfo * _Nonnull)info
   ```

Sets the mediation information, which provides details about your app's mediation integration, including mediation name, version, and adapter version.

| **Parameter** | **Description**                                     |
| ------------- | --------------------------------------------------- |
| info          | Specifies details about your mediation integration. |

**Returns**: The updated `UADSInitConfigurationBuilder` instance.

### withExtras:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withExtras:(NSDictionary<NSString *, NSString *> * _Nonnull)extras
   ```

Sets additional parameters.

| **Parameter** | **Description**                                      |
| ------------- | ---------------------------------------------------- |
| extras        | Additional key–value pairs for custom configuration. |

**Returns**: The updated `UADSInitConfigurationBuilder` instance.

### build

1. **Objective-C**

   ```objective-c
   - (UADSInitializationConfiguration * _Nonnull)build
   ```

Builds and returns a UADSInitializationConfiguration instance.

**Returns**: An instance of `UADSInitializationConfiguration`.

## UADSInterstitialAd

The `UADSInterstitialAd` class manages the loading and showing of interstitial ads.

### load:completion:\_

1. **Objective-C**

   ```objective-c
   @interface UADSInterstitialAd : NSObject
   + (void)load:(UADSLoadConfiguration * _Nonnull)configuration
     completion:(void (^ _Nonnull)(UADSInterstitialAd * _Nullable, id<UnityAdsError> _Nullable))completion;
   @end
   ```

Loads an interstitial ad with the specified configuration.

| **Parameters** | **Description**                                                                                                             |
| -------------- | --------------------------------------------------------------------------------------------------------------------------- |
| configuration  | An instance of UADSLoadConfiguration containing the ad loading options.                                                     |
| completion     | A callback that gets called when the loading process is finished. Returns either a UADSInterstitialAd instance or an error. |

### show:delegate:\_

1. **Objective-C**

   ```objective-c
   @interface UADSInterstitialAd : NSObject
   - (void)show:(UADSShowConfiguration * _Nullable)configuration
       delegate:(id <UADSInterstitialShowDelegate> _Nonnull)delegate;
   @end
   ```

Displays the loaded interstitial ad.

| **Parameter** | **Description**                                                              |
| ------------- | ---------------------------------------------------------------------------- |
| configuration | Optional configuration for showing the ad.                                   |
| delegate      | A delegate conforming to `UADSInterstitialShowDelegate` to handle ad events. |

### onAdExpired

Register a callback that gets triggered when the ad expires.

1. **Objective-C**

   ```objective-c
   @interface UnityAd : NSObject
   @property (nonatomic, copy) void (^ _Nullable onAdExpired)(UnityAd * _Nonnull);
   @end
   ```

## UADSLoadConfiguration

The `UADSLoadConfiguration` class encapsulates the options needed to load Unity ads. This includes specifying the placement ID, optional ad markup, and any additional parameters.

1. **Objective-C**

   ```objective-c
   @interface UADSLoadConfiguration: NSObject
   @property (nonatomic, strong) NSString *placementId;
   @property (nonatomic, strong, nullable) NSString *adMarkup;
   @property (nonatomic, strong, nullable) NSString *mediationAdUnitId;
   @property (nonatomic, strong, nullable) UADSMediationInfo *mediationInfo;
   @property (nonatomic, strong) NSDictionary<NSString *, NSString *> *extras;
   @end
   ```

Creates a new instance of `UADSLoadConfiguration`.

| **Property**        | **Description**                                                | **Required** |
| ------------------- | -------------------------------------------------------------- | ------------ |
| `placementId`       | The placement ID defined in the Unity Monetization Dashboard.  | Yes          |
| `adMarkup`          | Ad markup data that's used when loading an ad through bidding. | No           |
| `mediationAdUnitId` | The placement ID used in your mediation partner's dashboard.   | No           |
| `mediationInfo`     | Specifies details about your mediation integration.            | No           |
| `extras`            | Additional custom key–value pairs for configuration.           | No           |

| **Note:** The adMarkup property is required for all bidding implementations. For waterfall implementations, you can set adMarkup to nil. |
| ---------------------------------------------------------------------------------------------------------------------------------------- |

## UADSLoadConfigurationBuilder

Use `UADSLoadConfigurationBuilder` to create and return an instance of the `UADSLoadConfiguration` class.

### initWithPlacementId:\_

1. **Objective-C**

   ```objective-c
   - - (nonnull instancetype)initWithPlacementId:(NSString * _Nonnull)placementId;
   ```

Creates a new instance of `UADSLoadConfigurationBuilder`.

| **Parameter** | **Description**                                               |
| ------------- | ------------------------------------------------------------- |
| `placementId` | The placement ID defined in the Unity Monetization Dashboard. |

**Returns**: An instance of `UADSLoadConfigurationBuilder`.

### withAdMarkup:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withAdMarkup:(NSString * _Nonnull)adMarkup
   ```

Adds an adMarkup to the `UADSLoadConfigurationBuilder`.

| **Property** | **Description**                                                |
| ------------ | -------------------------------------------------------------- |
| `adMarkup`   | Ad markup data that's used when loading an ad through bidding. |

**Returns**: The updated `UADSLoadConfigurationBuilder` instance.

### withMediationAdUnitId:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withMediationAdUnitId:(NSString * _Nonnull)mediationAdUnitId
   ```

Adds the mediation ad unit ID to the `UADSLoadConfigurationBuilder`.

| **Property**        | **Description**                                              |
| ------------------- | ------------------------------------------------------------ |
| `mediationAdUnitId` | The placement ID used in your mediation partner's dashboard. |

**Returns**: The updated `UADSLoadConfigurationBuilder` instance.

### withMediationInfo:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withMediationInfo:(UADSMediationInfo * _Nonnull)info
   ```

Adds mediation information to the `UADSLoadConfigurationBuilder`.

| **Parameter** | **Description**                                                                      |
| ------------- | ------------------------------------------------------------------------------------ |
| mediationInfo | Specifies details about your mediation integration (name, version, adapter version). |

**Returns**: The updated `UADSLoadConfigurationBuilder` instance.

### withExtras:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withExtras:(NSDictionary<NSString *, NSString *> * _Nonnull)extras
   ```

Adds extra configuration key–value pairs to the `UADSLoadConfigurationBuilder`.

| **Parameter** | **Description**                                   |
| ------------- | ------------------------------------------------- |
| extras        | A dictionary of custom parameters for ad loading. |

**Returns**: The updated `UADSLoadConfigurationBuilder` instance.

### build

1. **Objective-C**

   ```objective-c
   - (UADSLoadConfiguration * _Nonnull)build
   ```

Builds and returns a `UADSLoadConfiguration` instance.

**Returns**: An instance of `UADSLoadConfiguration`.

### UADSLoadOptions

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use [`UADSLoadConfigurationBuilder`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsloadconfigurationbuilder) instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UADSLoadOptions` was the previous class for specifying ad load options.

## UADSMediationInfo

Specifies details about your mediation integration.

1. **Objective-C**

   ```objective-c
   @interface UADSMediationInfo : NSObject
   - (nonnull instancetype)initWithName:(NSString * _Nonnull)name
                                version:(NSString * _Nonnull)version
                         adapterVersion:(NSString * _Nonnull)adapterVersion
   @end
   ```

| **Parameters** | **Description**                                                  |
| -------------- | ---------------------------------------------------------------- |
| name           | The name of the mediation platform integrated in your app.       |
| version        | The version of the mediation SDK integrated in your app.         |
| adapterVersion | The version of the Unity Ads adapter for your mediation partner. |

**Returns**: An instance of `UADSMediationInfo`.

### UADSMediationMetaData

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use [`UADSMediationInfo`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsmediationinfo) instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UADSMediationMetaData` was the previous class for passing mediation partner information.

## UADSRewardedAd

The UADSRewardedAd class manages the loading and showing of rewarded ads.

### load:completion:\_

1. **Objective-C**

   ```objective-c
   + (void)load:(UADSLoadConfiguration * _Nonnull)configuration
     completion:(void (^ _Nonnull)(UADSRewardedAd * _Nullable, id<UnityAdsError> _Nullable))completion;
   ```

Loads a rewarded ad with the specified options.

| **Parameters** | **Description**                                                                                                                              |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| configuration  | An instance of UADSLoadConfiguration containing the ad loading options.                                                                      |
| completion     | A callback that gets called when ad loading finishes. Returns a UADSRewardedAd instance if successful, or an UnityAdsError if loading fails. |

### show:delegate:\_

1. **Objective-C**

   ```objective-c
   - (void)show:(UADSShowConfiguration * _Nullable)configuration
       delegate:(id <UADSRewardedShowDelegate> _Nonnull)delegate;
   ```

Displays the loaded rewarded ad.

| **Parameter** | **Description**                             |
| ------------- | ------------------------------------------- |
| configuration | Optional settings for showing the ad.       |
| delegate      | A delegate that handles rewarded ad events. |

### onAdExpired

Register a callback that gets triggered when the ad expires.

1. **Objective-C**

   ```objective-c
   @interface UnityAd : NSObject
   @property (nonatomic, copy) void (^ _Nullable onAdExpired)(UnityAd * _Nonnull);
   @end
   ```

## UADSShowConfiguration

The `UADSShowConfiguration` class specifies additional parameters that you want to pass in the form of key-value pairs when showing Unity Ads.

1. **Objective-C**

   ```objective-c
   @interface UADSShowConfigurationBuilder : NSObject
   @property (nonatomic, weak, nullable) UIViewController *viewController;
   @property (nonatomic, strong, nullable) NSString *customRewardString;
   @property (nonatomic, strong) NSDictionary<NSString *, NSString *> *extras;
   @end
   ```

Creates a new instance of `UADSShowConfiguration` with optional additional parameters.

| **Property**         | **Description**                                                                                  | **Required** |
| -------------------- | ------------------------------------------------------------------------------------------------ | ------------ |
| `viewController`     | The view controller used to present the ad.                                                      | No           |
| `customRewardString` | A custom reward identifier for the ad impression.                                                | No           |
| `extras`             | Additional key–value parameters to include when showing the ad. Defaults to an empty dictionary. | No           |

## UADSShowConfigurationBuilder

Use `UADSShowConfigurationBuilder` to create and return an instance of the `UADSShowConfiguration` class.

### init

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)init;
   ```

Creates a new instance of `UADSShowConfigurationBuilder`.

### withViewController:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withViewController:(UIViewController * _Nonnull)viewController
   ```

Sets the view controller to present the ad from.

| **Parameter**    | **Description**                        |
| ---------------- | -------------------------------------- |
| `viewController` | The view controller presenting the ad. |

**Returns**: The updated `UADSShowConfigurationBuilder` instance.

### withCustomRewardString:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withCustomRewardString:(NSString * _Nonnull)customRewardString
   ```

Sets a custom reward identifier for the ad impression.

| **Parameter**        | **Description**                           |
| -------------------- | ----------------------------------------- |
| `customRewardString` | A unique reward ID for the ad impression. |

**Returns**: The updated `ShowConfigurationBuilder` instance.

### withExtras:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withExtras:(NSDictionary<NSString *, NSString *> * _Nonnull)extras
   ```

Adds extra key–value parameters when showing the ad.

| **Parameter** | **Description**                   |
| ------------- | --------------------------------- |
| `extras`      | Custom parameters for ad display. |

**Returns**: The updated `UADSShowConfigurationBuilder` instance.

### build

1. **Objective-C**

   ```objective-c
   - (UADSShowConfiguration * _Nonnull)build
   ```

Builds and returns a `UADSShowConfiguration` instance.

**Returns**: An instance of `UADSShowConfiguration`.

### UADSShowOptions

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use [`UADSShowConfigurationBuilder`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsshowconfigurationbuilder) instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UADSShowOptions` was the previous class for specifying ad show options.

## UADSTokenConfiguration

1. **Objective-C**

   ```objective-c
   @interface UADSTokenConfiguration : NSObject
   @property (nonatomic, assign) AdFormat UADSAdFormat;
   @property (nonatomic, strong, nullable) UADSMediationInfo *mediationInfo;
   @property (nonatomic, strong, nullable) NSString *mediationAdUnitId;
   @property (nonatomic, strong, nullable) NSString *placementId;
   @property (nonatomic, assign) CGSize bannerSize;
   @property (nonatomic, strong) NSDictionary<NSString *, NSString *> *extras;
   @end
   ```

The `UADSTokenConfiguration` interface creates an object consisting of essential information required to get a bidding token.

| **Property**        | **Description**                                                   | **Required** |
| ------------------- | ----------------------------------------------------------------- | ------------ |
| `adFormat`          | Specifies the type of ad format (interstitial, rewarded, banner). | Yes          |
| `mediationInfo`     | Specifies details about your mediation integration.               | No           |
| `mediationAdUnitId` | The placement ID used in your mediation partner's dashboard.      | No           |
| `placementId`       | The placement ID defined in the Unity Monetization Dashboard.     | No           |
| `bannerSize`        | The size of the banner ad if a token requested a banner ad.       | No           |
| `extras`            | Additional key–value pairs for custom configuration.              | No           |

### UADSTokenConfigurationBuilder

Use `UADSTokenConfigurationBuilder` to create and return an instance of the `UADSTokenConfiguration` class.

### initWithAdFormat:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)initWithAdFormat:(enum UADSAdFormat)adFormat
   ```

Creates a new instance of `UADSTokenConfigurationBuilder`.

| **Parameter** | **Description**                                                                         |
| ------------- | --------------------------------------------------------------------------------------- |
| adFormat      | An instance of AdFormat that specifies the type of ad (interstitial, rewarded, banner). |

**Returns**: An instance of `UADSTokenConfigurationBuilder`.

### withMediationInfo:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withMediationInfo:(UADSMediationInfo * _Nonnull)mediationInfo
   ```

Specifies details about your mediation integration.

| **Parameter** | **Description**                                     |
| ------------- | --------------------------------------------------- |
| mediationInfo | Specifies details about your mediation integration. |

**Returns**: The updated `TokenConfigurationBuilder` instance.

### withMediationAdUnitId:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withMediationAdUnitId:(NSString * _Nonnull)mediationAdUnitId
   ```

Adds the mediation ad unit ID to the `TokenConfiguration`.

| **Property**        | **Description**                                              |
| ------------------- | ------------------------------------------------------------ |
| `mediationAdUnitId` | The placement ID used in your mediation partner's dashboard. |

**Returns**: The updated `UADSTokenConfigurationBuilder` instance.

### withPlacementId:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withPlacementId:(NSString * _Nonnull)placementId
   ```

Specifies the placement ID defined in the Unity Monetization Dashboard.

| **Parameter** | **Description**                                               |
| ------------- | ------------------------------------------------------------- |
| placementId   | The placement ID defined in the Unity Monetization Dashboard. |

**Returns**: The updated `UADSTokenConfigurationBuilder` instance.

### withBannerSize:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withBannerSize:(CGSize)bannerSize
   ```

Specifies the size of the banner ad if a token requested a banner ad.

| **Parameter** | **Description**                                             |
| ------------- | ----------------------------------------------------------- |
| bannerSize    | The size of the banner ad if a token requested a banner ad. |

**Returns**: The updated `UADSTokenConfigurationBuilder` instance.

### withExtras:\_

1. **Objective-C**

   ```objective-c
   - (nonnull instancetype)withExtras:(NSDictionary<NSString *, NSString *> * _Nonnull)extras
   ```

Specifies additional key–value pairs for custom configuration.

| **Parameter** | **Description**                                      |
| ------------- | ---------------------------------------------------- |
| extras        | Additional key–value pairs for custom configuration. |

**Returns**: The updated `UADSTokenConfigurationBuilder` instance.

### build

1. **Objective-C**

   ```objective-c
   - (UADSTokenConfiguration * _Nonnull)build
   ```

Builds and returns a `UADSTokenConfiguration` instance.

**Returns**: An instance of `UADSTokenConfiguration`.

## UnityAds

The `UnityAds` class is a static class that serves as the primary entry point for the SDK. It handles initialization, token retrieval, privacy consent, and provides access to global SDK properties.

### Initialization

#### initialize(\_, completion:)

Initializes the Unity Ads SDK with a specified configuration. The completion block is called when initialization completes with either success or failure.

1. **Objective-C**

   ```objective-c
   + (void) initialize:(UADSInitializationConfiguration *) configuration
            completion:(void (^)(id<UnityAdsError> )) completion;
   ```

| **Parameter** | **Description**                                                                                                 |
| ------------- | --------------------------------------------------------------------------------------------------------------- |
| configuration | The UADSInitializationConfiguration object that contains the required settings to initialize the SDK.           |
| completion    | A callback that gets called when SDK initialization finishes. Returns an UnityAdsError if initialization fails. |

### GetToken

#### getToken(\_, completion:)

Fetches a bidding token based on the provided `UADSTokenConfiguration` and passes it to the completion block.

1. **Objective-C**

   ```objective-c
   + (void) getToken:(UADSTokenConfiguration *) configuration
          completion:(void (^)(NSString * )) completion;
   ```

| **Parameter** | **Description**                                                                                            |
| ------------- | ---------------------------------------------------------------------------------------------------------- |
| configuration | A `UADSTokenConfiguration` object that specifies the ad format, mediation info, and other parameters.      |
| completion    | A completion block that is called with the token if it's successfully fetched, or null if an error occurs. |

### Static variables

#### IsInitialized

Determines if the Unity Ads SDK is initialized successfully.

1. **Objective-C**

   ```objective-c
   + (BOOL)isInitialized
   ```

**Returns**: If `true`, Unity Ads has been successfully initialized.

#### getVersion

Determines the current Unity Ads SDK version in use.

1. **Objective-C**

   ```objective-c
   + (NSString *)getVersion
   ```

**Returns**: The current installed version of Unity Ads SDK.

#### userIdentifier

Sets a unique ID for each user of your app.

1. **Objective-C**

   ```objective-c
   @objc public static var userIdentifier: String {...}
   ```

### Privacy

#### setUserConsent()

Displays the user's opt-in choices for personalized ads.

1. **Objective-C**

   ```objective-c
   + (void)setUserConsent:(BOOL)consentGranted;
   ```

#### setUserOptOut()

Offers users the option to opt out of data collection and personalized ads.

1. **Objective-C**

   ```objective-c
   + (void)setUserOptOut:(BOOL)optOut;
   ```

#### setNonBehavioral()

Enables the display of contextual (non-personalized) ads.

1. **Objective-C**

   ```objective-c
   + (void)setNonBehavioral:(BOOL)nonBehavioral;
   ```

### UADSMetaData

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use the typed privacy methods on [`UnityAds`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#unityads): `setUserConsent:`, `setUserOptOut:`, and `setNonBehavioral:`. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UADSMetaData` was the previous class for setting GDPR and other privacy-related flags.

### UnityAdsInitializationDelegate

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use a completion block with [`UnityAds initialize:completion:`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#unityads) instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UnityAdsInitializationDelegate` was the previous delegate protocol for SDK initialization callbacks.

### UnityAdsLoadDelegate

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use a completion block with [`UADSInterstitialAd load:completion:`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsinterstitialad) or [`UADSRewardedAd load:completion:`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsrewardedad) instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UnityAdsLoadDelegate` was the previous delegate protocol for ad loading callbacks.

### UnityAdsShowDelegate

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use [`UADSInterstitialShowDelegate`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsinterstitialshowdelegate) or [`UADSRewardedShowDelegate`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsrewardedshowdelegate) instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UnityAdsShowDelegate` was the previous delegate protocol for ad show callbacks.

## Enum

### UADSAdFormat

Defines the different types of ad formats supported by Unity Ads.

1. **Objective-C**

   ```objective-c
   typedef enum {
     UADSAdFormatUnspecified = 0,
     UADSAdFormatInterstitial = 1,
     UADSAdFormatRewarded = 2,
     UADSAdFormatBanner = 3,
   } UADSAdFormat;
   ```

| **Parameter**            | **Description**                                                                                           |
| ------------------------ | --------------------------------------------------------------------------------------------------------- |
| UADSAdFormatUnspecified  | No specified ad format.                                                                                   |
| UADSAdFormatInterstitial | Full-screen ads shown at natural pauses in the app.                                                       |
| UADSAdFormatRewarded     | Ads that grant users a reward after completion.                                                           |
| UADSAdFormatBanner       | Rectangular ads displayed within the app's layout, typically anchored to the top or bottom of the screen. |

### UnityAdsAdFormat

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use [`UADSAdFormat`](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md#uadsadformat) instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UnityAdsAdFormat` was the previous enum for ad format types.

### UADSLogLevel

Defines the logging levels for Unity Ads.

1. **Objective-C**

   ```objective-c
   typedef enum {
     UADSLogLevelDisabled = 0,
     UADSLogLevelError = 1,
     UADSLogLevelInfo = 2,
     UADSLogLevelDebug = 3,
   } UADSLogLevel;
   ```

| **Parameter**        | **Description**                                                                                                                              |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| UADSLogLevelDisabled | No logs output.                                                                                                                              |
| UADSLogLevelError    | Logs only critical errors and failures in init/load/show operations.                                                                         |
| UADSLogLevelInfo     | Logs key operational events (such as initialization started/completed, load started/completed, show started/finished, and token generation). |
| UADSLogLevelDebug    | Logs all info plus detailed internal operations like network requests and internal errors.                                                   |

### UADSShowFinishState

Represents the finish state of an ad after it has been shown.

1. **Objective-C**

   ```objective-c
   typedef enum {
     UADSShowFinishStateSkipped = 0,
     UADSShowFinishStateCompleted = 1,
   } UADSShowFinishState
   ```

| **Parameter**                | **Description**                                       |
| ---------------------------- | ----------------------------------------------------- |
| UADSShowFinishStateSkipped   | The user closed or skipped the ad before it finished. |
| UADSShowFinishStateCompleted | The ad played until the end.                          |

## Protocol

### UADSBannerAdDelegate

1. **Objective-C**

   ```objective-c
   @protocol UADSBannerAdDelegate <NSObject>
   - (void)bannerImpression:(UADSBannerAd * _Nonnull)banner;
   - (void)bannerDidClick:(UADSBannerAd * _Nonnull)banner;
   - (void)bannerDidFailShow:(UADSBannerAd * _Nonnull)banner error:(id<UnityAdsError> _Nonnull)error;
   @end
   ```

| **Method**                 | **Description**                                                                        |
| -------------------------- | -------------------------------------------------------------------------------------- |
| `bannerImpression:`        | Called when a banner ad is displayed (impression recorded).                            |
| `bannerDidClick:`          | Called when the user clicks the banner ad.                                             |
| `bannerDidFailShow:error:` | Called if the banner fails to display, with an `UnityAdsError` explaining the failure. |

### UADSInterstitialShowDelegate

1. **Objective-C**

   ```objective-c
   @protocol UADSInterstitialShowDelegate <NSObject>
   - (void)showDidStart:(UADSInterstitialAd * _Nonnull)unityAd;
   - (void)showDidClick:(UADSInterstitialAd * _Nonnull)unityAd;
   - (void)showDidComplete:(UADSInterstitialAd * _Nonnull)unityAd with:(enum UADSShowFinishState)finishState;
   - (void)showDidFail:(UADSInterstitialAd * _Nonnull)unityAd error:(id<UnityAdsError> _Nonnull)error;
   @end
   ```

| **Method**              | **Description**                                                                                   |
| ----------------------- | ------------------------------------------------------------------------------------------------- |
| `showDidStart:`         | Called when the interstitial ad starts showing.                                                   |
| `showDidClick:`         | Called when the interstitial ad is clicked.                                                       |
| `showDidComplete:with:` | Called when the ad finishes showing. Provides a `UADSShowFinishState` (`skipped` or `completed`). |
| `showDidFail:error:`    | Called if the ad fails to show, with an `UnityAdsError` explaining the failure.                   |

### UADSRewardedShowDelegate

1. **Objective-C**

   ```objective-c
   @protocol UADSRewardedShowDelegate <NSObject>
   - (void)showDidStart:(UADSRewardedAd * _Nonnull)unityAd;
   - (void)showDidClick:(UADSRewardedAd * _Nonnull)unityAd;
   - (void)showDidComplete:(UADSRewardedAd * _Nonnull)unityAd with:(enum UADSShowFinishState)finishState;
   - (void)showDidFail:(UADSRewardedAd * _Nonnull)unityAd error:(id<UnityAdsError> _Nonnull)error;
   - (void)showDidReceiveReward:(UADSRewardedAd * _Nonnull)unityAd;
   @end
   ```

| **Method**              | **Description**                                                                                   |
| ----------------------- | ------------------------------------------------------------------------------------------------- |
| `showDidStart:`         | Called when the rewarded ad starts showing.                                                       |
| `showDidClick:`         | Called when the rewarded ad is clicked.                                                           |
| `showDidComplete:with:` | Called when the ad finishes showing. Provides a `UADSShowFinishState` (`skipped` or `completed`). |
| `showDidFail:error:`    | Called if the ad fails to show, with an `UnityAdsError` explaining the failure.                   |
| `showDidReceiveReward:` | Called when the user earns the reward from the ad.                                                |

## UnityAdsError

1. **Objective-C**

   ```objective-c
   @protocol UnityAdsError
   @property (nonatomic, readonly) NSInteger code;
   @property (nonatomic, readonly, copy) NSString * _Nonnull message;
   @end
   ```

| **Parameter** | **Description** |
| ------------- | --------------- |
| code          |                 |
| message       |                 |

### UADSBannerErrorCode

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use the `id<UnityAdsError>` protocol instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UADSBannerErrorCode` was the previous enum for banner-specific error codes.

### UnityAdsInitializationError

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use the `id<UnityAdsError>` protocol instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UnityAdsInitializationError` was the previous enum for initialization error types.

### UnityAdsLoadError

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use the `id<UnityAdsError>` protocol instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UnityAdsLoadError` was the previous enum for ad load error types.

### UnityAdsShowError

> **Warning:**
>
> **Deprecated in version 4.19.0. Scheduled for removal in version 5.0.0.**
>
> Use the `id<UnityAdsError>` protocol instead. See [iOS deprecated APIs](/ads-ios/4.19.0/sdk-integration/api/ios-deprecated-apis.md) for migration details.

`UnityAdsShowError` was the previous enum for ad show error types.
