---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://boost.yandex.ru/doc/en/ad-monetization/dev/react-native/react-native-migration-800.md
  - https://boost.yandex.ru/doc/ru/ad-monetization/dev/react-native/react-native-migration-800.md
  - href: en/ad-monetization/dev/react-native/react-native-migration-800.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://boost.yandex.ru/doc/en/llms.txt

# Guide to migrating to version 8

Several callbacks and APIs incompatible with the new native SDK version were removed in plugin version 8.0.0. This guide will help you make the necessary updates to your app's code.


## 1. Removing `BannerView` callbacks

The following properties of the `BannerView` component were removed and are no longer supported:

| Properties | Platform |
|-------|-----------|
| `onLeftApplication` | iOS, Android |
| `onWillPresentScreen` | iOS |
| `onDidDismissScreen` | iOS |
| `onReturnToApplication` | Android |
| `onAdClose` | iOS, Android |

**What to do:** Remove these properties from all `BannerView` instances.

#### Before

```tsx
<BannerView
  adRequest={{ adUnitId: 'R-M-XXXXX-YY' }}
  size={adSize}
  onAdLoaded={() => console.log('loaded')}
  onAdClicked={() => console.log('clicked')}
  onLeftApplication={() => console.log('left app')}
  onWillPresentScreen={() => console.log('will present')}
  onDidDismissScreen={() => console.log('did dismiss')}
  onReturnToApplication={() => console.log('returned')}
  onAdClose={() => console.log('closed')}
  onAdImpression={(e) => console.log('impression', e)}
  onAdFailedToLoad={(e) => console.log('failed', e)}
/>
```

#### After

```tsx
<BannerView
  adRequest={{ adUnitId: 'R-M-XXXXX-YY' }}
  size={adSize}
  onAdLoaded={() => console.log('loaded')}
  onAdClicked={() => console.log('clicked')}
  onAdImpression={(e) => console.log('impression', e)}
  onAdFailedToLoad={(e) => console.log('failed', e)}
/>
```

## 2. Replacing `AdRequestConfiguration` with `AdRequest`

The `AdRequestConfiguration` class has been removed. Request parameters, including `adUnitId`, are now passed directly to the `loadAd` method via an `AdRequestParams` object.

**What to do:**
- Remove any imports or instances of `AdRequestConfiguration`.
- Pass the `adUnitId` directly to `loadAd` along with the rest of the parameters.

#### Before

```tsx
import { InterstitialAdLoader, AdRequestConfiguration, Gender } from '@yandex-ads/react-native-yandex-ads';

const loader = await InterstitialAdLoader.create();
const config = new AdRequestConfiguration({
  adUnitId: 'R-M-XXXXX-YY',
  age: '25',
  gender: Gender.Male,
});
const ad = await loader.loadAd(config);
```

#### After

```tsx
import { InterstitialAdLoader, Gender } from '@yandex-ads/react-native-yandex-ads';

const loader = await InterstitialAdLoader.create();
const ad = await loader.loadAd({
  adUnitId: 'R-M-XXXXX-YY',
  targeting: {
    age: '25',
    gender: Gender.Male,
  },
});
```

These changes apply to `RewardedAdLoader` and `AppOpenAdLoader`.

## 3. Moving the `adUnitId` property from `BannerView` to `adRequest`

The `adUnitId` property has been removed from `BannerView`. The ad unit ID is now passed as a required field of the `adRequest` object.

**What to do:** Remove the `adUnitId` property from `BannerView` and move it to `adRequest.adUnitId`.

#### Before

```tsx
<BannerView
  adUnitId="R-M-XXXXX-YY"
  size={adSize}
/>
```

#### After

```tsx
<BannerView
  size={adSize}
  adRequest={{ adUnitId: 'R-M-XXXXX-YY' }}
/>
```

## 4. Moving the targeting fields to the `targeting` object

`age`, `gender`, `location`, `contextQuery`, and `contextTags` fields have been moved to the nested `targeting` object. This applies to both fullscreen formats as well as `BannerView`.

**What to do:** Wrap the targeting fields in `targeting: { ... }`.

### Fullscreen ads (Interstitial, Rewarded, AppOpen)

#### Before

```ts
loader.loadAd({
  adUnitId: 'R-M-XXXXX-YY',
  age: '25',
  gender: Gender.Male,
  contextTags: ['sport', 'news'],
});
```

#### After

```tsx
loader.loadAd({
  adUnitId: 'R-M-XXXXX-YY',
  targeting: {
    age: '25',
    gender: Gender.Male,
    contextTags: ['sport', 'news'],
  },
});
```

### `BannerView`

#### Before

```tsx
import { Gender } from '@yandex-ads/react-native-yandex-ads';

<BannerView
  adUnitId="R-M-XXXXX-YY"
  size={adSize}
  adRequest={{ age: '25', gender: Gender.Male }}
/>
```

#### After

```tsx
import { Gender } from '@yandex-ads/react-native-yandex-ads';

<BannerView
  size={adSize}
  adRequest={{ adUnitId: 'R-M-XXXXX-YY', targeting: { age: '25', gender: Gender.Male } }}
/>
```

## 5. New `AdInfo` interface

Version 8.0.0 adds the `AdInfo` interface, which contains metadata about loaded ads.

```ts
interface AdInfo {
  adUnitId: string;
  extraData?: string;
  partnerText?: string;
  creatives: Creative[];
}

interface Creative {
  creativeId?: string;
  campaignId?: string;
  placeId?: string;
  offerId?: string;
}
```

### Getting `AdInfo` for fullscreen formats

The `InterstitialAd`, `RewardedAd`, and `AppOpenAd` objects now contain the `adInfo` getter:

```ts
const ad = await loader.loadAd({ adUnitId: 'R-M-XXXXX-YY' });
console.log(ad.adInfo?.adUnitId);
console.log(ad.adInfo?.creatives);
```

### Getting `AdInfo` in `BannerView`

The `onAdLoaded` callback now accepts an event containing the `adInfo` field:

```tsx
<BannerView
  size={adSize}
  adRequest={{ adUnitId: 'R-M-XXXXX-YY' }}
  onAdLoaded={(event) => {
    const adInfo = event.nativeEvent.adInfo;
    console.log(adInfo?.adUnitId);
  }}
/>
```

## 6. Version requirements

### iOS

- **Xcode**: 16.4 or higher.
- **AppMetricaCore**: 6.0.0 or higher.
- **AppMetricaLibraryAdapter**: 6.0.0 or higher.
- **AppMetricaAdSupport**: 6.0.0 or higher.
- **AppMetricaIDSync**: 6.0.0 or higher.

### Android

- **Gradle**: 7.0 or higher.
- **Android gradle plugin**: 8.3.2 or higher.
- **Android SDK**: 21 (Android 5.0) or higher.
- **Kotlin**: 1.9.0 or higher.
- **Java**: 8 or higher.
