Guide for migrating to version 8
Plugin version 8.0.0 removes some callbacks and APIs that are incompatible with the new native SDK. This guide lists the code changes you need.
1. Removed BannerView callbacks
The following BannerView props are removed and no longer supported:
| Prop | Platform |
|---|---|
onLeftApplication |
iOS, Android |
onWillPresentScreen |
iOS |
onDidDismissScreen |
iOS |
onReturnToApplication |
Android |
onAdClose |
iOS, Android |
What to do: remove these props everywhere you use BannerView.
Before
<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
<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. Replace AdRequestConfiguration with AdRequest
AdRequestConfiguration is removed. Pass request parameters, including adUnitId, directly to loadAd as AdRequestParams.
What to do:
- remove imports and construction of
AdRequestConfiguration; - pass
adUnitIdand other fields directly toloadAd.
Before
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
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,
},
});
The same applies to RewardedAdLoader and AppOpenAdLoader.
3. Move adUnitId from BannerView props into adRequest
The adUnitId prop is removed from BannerView. The ad unit ID is now a required field inside adRequest.
What to do: remove the adUnitId prop and set adRequest.adUnitId.
Before
<BannerView
adUnitId="R-M-XXXXX-YY"
size={adSize}
/>
After
<BannerView
size={adSize}
adRequest={{ adUnitId: 'R-M-XXXXX-YY' }}
/>
4. Move targeting into a targeting object
age, gender, location, contextQuery, and contextTags are nested under targeting for fullscreen formats and BannerView.
What to do: wrap those fields in targeting: { ... }.
Fullscreen (interstitial, rewarded, app open)
Before
loader.loadAd({
adUnitId: 'R-M-XXXXX-YY',
age: '25',
gender: Gender.Male,
contextTags: ['sport', 'news'],
});
After
loader.loadAd({
adUnitId: 'R-M-XXXXX-YY',
targeting: {
age: '25',
gender: Gender.Male,
contextTags: ['sport', 'news'],
},
});
BannerView
Before
import { Gender } from '@yandex-ads/react-native-yandex-ads';
<BannerView
adUnitId="R-M-XXXXX-YY"
size={adSize}
adRequest={{ age: '25', gender: Gender.Male }}
/>
After
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 AdInfo with metadata for a loaded ad.
interface AdInfo {
adUnitId: string;
extraData?: string;
partnerText?: string;
creatives: Creative[];
}
interface Creative {
creativeId?: string;
campaignId?: string;
placeId?: string;
offerId?: string;
}
AdInfo for fullscreen formats
InterstitialAd, RewardedAd, and AppOpenAd expose an adInfo getter:
const ad = await loader.loadAd({ adUnitId: 'R-M-XXXXX-YY' });
console.log(ad.adInfo?.adUnitId);
console.log(ad.adInfo?.creatives);
AdInfo in BannerView
onAdLoaded receives an event with adInfo:
<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: 26.0 or later.
- AppMetricaCore: 6.0.0 or later.
- AppMetricaLibraryAdapter: 6.0.0 or later.
- AppMetricaAdSupport: 6.0.0 or later.
- AppMetricaIDSync: 6.0.0 or later.
Android
- Gradle: 7.0 or later.
- Android Gradle Plugin: 8.3.2 or later.
- Android SDK: API 21 (Android 5.0) or later.
- Kotlin: 1.9.0 or later.
- Java: 8 or later.