<br />

![](https://developers.google.com/static/admob/images/format-native.svg)

Native ads are ad assets that are presented to users through UI components that
are native to the platform. They're shown using the same classes you already use
in your storyboards, and can be formatted to match your app's visual design.

When a native ad loads, your app receives an ad object that contains its assets,
and the app---rather than Google Mobile Ads SDK---is then
responsible for displaying them.

Broadly speaking, there are two parts to successfully implementing native ads:
Loading an ad using the SDK and then displaying the ad content in your app.

This page shows how to use the SDK to load

[native ads](https://support.google.com/admanager/answer/6066199).


## Prerequisites

Before you continue, [set up Google Mobile Ads SDK](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/quick-start.md.txt).

## Always test with test ads

When building and testing your apps, make sure you use test ads rather than
live, production ads.

The easiest way to load test ads is to use our dedicated test ad unit ID for
native ads on iOS:

`/21775744923/example/native`

It's been specially configured to return test ads for every request, and you can
use it in your own apps while coding, testing, and debugging. Just make sure you
replace it with your own ad unit ID before publishing your app.

For details on Google Mobile Ads SDK test ads, see
[Enable test ads](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/test-ads.md.txt).

## Load ads

Native ads are loaded with the
[`GADAdLoader`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Classes/GADAdLoader.md.txt)
class, which send messages to their delegates according to the
[`GADAdLoaderDelegate`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Protocols/GADAdLoaderDelegate.md.txt)
protocol.

In addition to the system-defined native format, you can also create your
own [custom native ad formats](https://support.google.com/admanager/answer/6223271)
that can be used for direct-sold native ads. Custom native ad formats let you
pass arbitrary structured data to your app. These ads are represented by the
`GADCustomNativeAd` class.

### Initialize the ad loader

Before you can load an ad, you have to initialize the ad loader.
The following code demonstrates how to initialize a `GADAdLoader`:

### Swift

```swift
adLoader = AdLoader(
  adUnitID: "nativeAdUnitID",
  // The UIViewController parameter is optional.
  rootViewController: self,
  // To receive native ads, the ad loader's delegate must
  // conform to the NativeAdLoaderDelegate protocol.
  adTypes: [.native],
  // Use nil for default options.
  options: nil)
// Set the delegate before making an ad request.
adLoader.delegate = self
```

Replace <var translate="no">nativeAdUnitID</var> with your ad unit ID.

### Objective-C

```objective-c
self.adLoader =
    [[GADAdLoader alloc] initWithAdUnitID:"kNativeAdUnitID"
                       // The UIViewController parameter is optional.
                       rootViewController:self
                                  // To receive native ads, the ad loader's delegate must
                                  // conform to the NativeAdLoaderDelegate protocol.
                                  adTypes:@[ GADAdLoaderAdTypeNative ]
                                  // Use nil for default options.
                                  options:nil];
// Set the delegate before making an ad request.
self.adLoader.delegate = self;
```

Replace <var translate="no">kNativeAdUnitID</var> with your ad unit ID.

You'll need an ad unit ID (you can use the test ID), constants to pass in the
`adTypes` array to specify which native formats you want to request, and any
options you want to set in the `options` parameter. The list of possible
values for the `options` parameter can be found in the [Setting Native Ad
Options page](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/native/options).

The `adTypes` array should contain one or more of the following constants
:

- [`GADAdLoaderAdTypeNative`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Constants.md.txt#/c:@GADAdLoaderAdTypeNative)

<!-- -->

- [`GADAdLoaderAdTypeCustomNative`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Constants.md.txt#/c:@GADAdLoaderAdTypeCustomNative)

### Implement the ad loader delegate

The ad loader delegate needs to implement protocols specific to your ad type.
For native ads, the `GADNativeAdLoaderDelegate` protocol includes a message
that's sent to the delegate when a native ad has loaded.

### Swift

```swift
func adLoader(_ adLoader: AdLoader, didReceive nativeAd: NativeAd) {
  // Set the delegate to receive notifications for interactions with the native ad.
  nativeAd.delegate = self

  // TODO: Display the native ad.
}
```

### Objective-C

```objective-c
- (void)adLoader:(GADAdLoader *)adLoader didReceiveNativeAd:(GADNativeAd *)nativeAd {
  // Set the delegate to receive notifications for interactions with the native ad.
  nativeAd.delegate = self;

  // TODO: Display the native ad.
}
```

The `GADCustomNativeAdLoaderDelegate` protocol includes a message that's sent to
the delegate when a custom template ad has loaded.

### Swift

```swift
func adLoader(_ adLoader: AdLoader, didReceive customNativeAd: CustomNativeAd) {
  // To be notified of events related to the custom native ad interactions, set the delegate
  // property of the native ad
  customNativeAd.delegate = self

  // TODO: Display the custom native ad.
}
```

### Objective-C

```objective-c
- (void)adLoader:(GADAdLoader *)adLoader
    didReceiveCustomNativeAd:(GADCustomNativeAd *)customNativeAd {
  // To be notified of events related to the custom native ad interactions, set the delegate
  // property of the native ad
  customNativeAd.delegate = self;

  // TODO: Display the custom native ad.
}
```

### Request ads


> [!TIP]
> **Tip:** You can use ad load calls to build up a cache of preloaded ads before you intend to show them, so that ads can be shown with zero latency when needed. Because ads expire after an hour, you should clear this cache and reload with new ads every hour.

<br />

Once your `GADAdLoader` is initialized, call its `loadRequest:` method to
request an ad:

### Swift

```swift
adLoader.load(AdManagerRequest())
```

### Objective-C

```objective-c
[self.adLoader loadRequest:[GAMRequest request]];
```

The
[`loadRequest:`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Classes/GADAdLoader.md.txt#-loadrequest)
method in
[`GADAdLoader`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Classes/GADAdLoader.md.txt)
accepts the same
[`GAMRequest`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Classes/GAMRequest.md.txt)
objects as banners and interstitials. You can use request objects to [add
targeting information](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/targeting), just as you
would with other ad types.

#### Load multiple ads (optional)

To load multiple ads in a single request, set the
[`GADMultipleAdsAdLoaderOptions`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Classes/GADMultipleAdsAdLoaderOptions.md.txt)
object when initializing a `GADAdLoader`.

### Swift

```swift
let multipleAdOptions = MultipleAdsAdLoaderOptions()
multipleAdOptions.numberOfAds = 5
adLoader = AdLoader(
  adUnitID: "nativeAdUnitID",
  // The UIViewController parameter is optional.
  rootViewController: self,
  adTypes: [.native],
  options: [multipleAdOptions])
```

### Objective-C

```objective-c
GADMultipleAdsAdLoaderOptions *multipleAdOptions = [[GADMultipleAdsAdLoaderOptions alloc] init];
multipleAdOptions.numberOfAds = 5;

self.adLoader = [[GADAdLoader alloc] initWithAdUnitID:"kNativeAdUnitID"
                                   // The UIViewController parameter is optional.
                                   rootViewController:self
                                              adTypes:@[ GADAdLoaderAdTypeNative ]
                                              options:@[ multipleAdOptions ]];
```

The number of ads per request is capped at five, and it's not guaranteed that
the SDK will return the exact number of ads requested.

Returned Google ads will all be different from each other, though ads from
reserved inventory or third-party buyers are not guaranteed to be unique.

Don't use the `GADMultipleAdsAdLoaderOptions` class if you're using mediation,
as requests for multiple native ads don't work for ad unit IDs that have been
configured for mediation.

### Determine when loading has finished

After an app calls `loadRequest:`, it can get the results of the request using
calls to:

- [`adLoader:didFailToReceiveAdWithError:`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Protocols/GADAdLoaderDelegate.md.txt) in `GADAdLoaderDelegate`
- [`adLoader:didReceiveNativeAd:`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Protocols/GADNativeAdLoaderDelegate.md.txt) in `GADNativeAdLoaderDelegate`

A request for a single ad will result in one call to one of those methods.

A request for multiple ads will result in at least one callback to the above
methods, but no more than the maximum number of ads requested.

In addition, `GADAdLoaderDelegate` offers the `adLoaderDidFinishLoading`
callback. This delegate method indicates that an ad loader has finished loading
ads and no other ads or errors will be reported for the request. Here's an
example of how to use it when loading several native ads at one time:

### Swift

```swift
func adLoaderDidFinishLoading(_ adLoader: AdLoader) {
  // The adLoader has finished loading ads.
}
```

### Objective-C

```objective-c
- (void)adLoaderDidFinishLoading:(GADAdLoader *)adLoader {
  // The adLoader has finished loading ads.
}
```

### Handle failed requests

The protocols extend the `GADAdLoaderDelegate` protocol, which defines a
message sent when ads fail to load.

### Swift

```swift
func adLoader(_ adLoader: AdLoader, didFailToReceiveAdWithError error: any Error) {
  // The adLoader failed to receive an ad.
}
```

### Objective-C

```objective-c
- (void)adLoader:(GADAdLoader *)adLoader didFailToReceiveAdWithError:(NSError *)error {
  // The adLoader failed to receive an ad.
}
```

> [!WARNING]
> **Warning:** Attempting to load a new ad from the `adLoader:didFailToReceiveAdWithError:` delegate method is strongly discouraged. If you must load an ad from `adLoader:didFailToReceiveAdWithError:`, limit ad load retries to avoid continuous failed ad requests in situations such as limited network connectivity.

#### Get notified of native ad events

To be notified of events related to the native ad interactions, set the delegate
property of the native ad:

### Swift

```swift
nativeAd.delegate = self
```

### Objective-C

```objective-c
nativeAd.delegate = self;
```

Then implement
[`GADNativeAdDelegate`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Classes/GADNativeAd.md.txt#delegate)
to receive the following delegate calls:

### Swift

```swift
func nativeAdDidRecordImpression(_ nativeAd: NativeAd) {
  // The native ad was shown.
}

func nativeAdDidRecordClick(_ nativeAd: NativeAd) {
  // The native ad was clicked on.
}

func nativeAdWillPresentScreen(_ nativeAd: NativeAd) {
  // The native ad will present a full screen view.
}

func nativeAdWillDismissScreen(_ nativeAd: NativeAd) {
  // The native ad will dismiss a full screen view.
}

func nativeAdDidDismissScreen(_ nativeAd: NativeAd) {
  // The native ad did dismiss a full screen view.
}

func nativeAdWillLeaveApplication(_ nativeAd: NativeAd) {
  // The native ad will cause the app to become inactive and
  // open a new app.
}
```

### Objective-C

```objective-c
- (void)nativeAdDidRecordImpression:(GADNativeAd *)nativeAd {
  // The native ad was shown.
}

- (void)nativeAdDidRecordClick:(GADNativeAd *)nativeAd {
  // The native ad was clicked on.
}

- (void)nativeAdWillPresentScreen:(GADNativeAd *)nativeAd {
  // The native ad will present a full screen view.
}

- (void)nativeAdWillDismissScreen:(GADNativeAd *)nativeAd {
  // The native ad will dismiss a full screen view.
}

- (void)nativeAdDidDismissScreen:(GADNativeAd *)nativeAd {
  // The native ad did dismiss a full screen view.
}

- (void)nativeAdWillLeaveApplication:(GADNativeAd *)nativeAd {
  // The native ad will cause the app to become inactive and
  // open a new app.
}
```

### Best practices

Follow these rules when loading ads.

- Apps that use native ads in a list should precache the list of ads.

- When precaching ads, clear your cache and reload after one hour.

- Don't call `loadRequest:` again on a `GADAdLoader` until the previous request
  finishes loading, as indicated by [`adLoaderDidFinishLoading:`](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Protocols/GADAdLoaderDelegate.md.txt#-adloaderdidfinishloading:).

- Limit native ad caching to only what is needed. For example when precaching,
  only cache the ads that are immediately visible on the screen. Native ads
  have a large memory footprint, and caching native ads without destroying them
  results in excessive memory use.

- Destroy native ads when no longer in use.

## Display your ad

Once you have loaded an ad, all that remains is to display it to your users.
For more information, see [Native advanced](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/native/advanced.md.txt) or
[Full-screen native ads](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/native/full-screen.md.txt).