Warning
Be sure to update to the latest adapter versions (Yandex Mediation). Otherwise, errors from improper adapter integration might occur, preventing the ad from being served.
Banners
Renamed the AdSize class to BannerAdSize. Removed the flexibleSize(int width, int maxHeight) method.
Use methods depending on your ad type:
To create an adaptive sticky banner, use the BannerAdSize.stickySize(int width) method.
An adaptive sticky banner is a small, automatically updated ad placed at the bottom or top of the app screen.
The banner doesn't overlap the main app content and is often used in gaming apps.
The height of the sticky banner is determined automatically, adapting to the device screen size and not exceeding 15% of the screen height.
Warning
Starting with version 6.0.0, adaptive sticky banners can refresh automatically.
If you previously implemented auto-refresh for a sticky-banner, you should now disable it.
To create an adaptive inline banner, use the BannerAdSize.inlineSize(int width, int maxHeight) method.
An adaptive inline banner is a flexible banner ad format that ensures maximum efficiency by optimizing ad size for each device.
The banner height is selected automatically and can reach the height of the device screen.
Typically, this format is used in feed-based apps or contexts where it's acceptable to primarily focus user attention on ads.
Rewarded ads
The approach to creating and loading advertisements has been revised. We now provide the RewardedAdLoader loader object, which loads the ads, and the RewardedAd ad object retrieved from the onAdLoaded ad load event.
|
Loading ads
|
SDK 5
One object is now used both for loading and serving ads:
final ad = await RewardedAd.create(
adUnitId: 'your-ad-unit-id',
onAdLoaded: () {
},
onAdFailedToLoad: (error) {
},
);
await ad.load(adRequest: AdRequest());
SDK 6
RewardedAdLoader is used for loading multiple ads.
late final Future<RewardedAdLoader> _adLoader =
_createRewardedAdLoader();
RewardedAd? _ad;
Future<RewardedAdLoader> _createRewardedAdLoader() {
return RewardedAdLoader.create(
onAdLoaded: (RewardedAd rewardedAd) {
_ad = rewardedAd;
},
onAdFailedToLoad: (error) {
},
);
}
Future<void> _loadRewardedAd() async {
final adLoader = await _adLoader;
await adLoader.loadAd(adRequestConfiguration: AdRequestConfiguration(adUnitId: 'your-ad-unit-id'));
}
|
|
Ad serving
|
SDK 5
Check if the ad is loaded before displaying it.
RewardedAd? _ad;
Future<void> _showRewardedAd() async {
final ad = _ad;
if (ad != null && ad.isLoaded) {
await ad.show();
var reward = await ad.waitForDismiss();
}
}
SDK 6
You don't need to check whether the ad has been loaded. The ad is ready for rendering after it is returned by the onAdLoaded() callback method.
RewardedAd? _ad;
Future<void> _showRewardedAd() async {
final ad = _ad;
if (ad != null) {
_setAdEventListener(ad);
await ad.show();
var reward = await ad.waitForDismiss();
}
}
|
|
Subscribing to ad lifecycle events
|
SDK 5
All events come in a single RewardedAd object.
RewardedAd.create(
onAdLoaded: () {},
onAdFailedToLoad: (AdLoadError error) {},
onAdShown: () {},
onAdDismissed: () {},
onRewarded: (Reward reward) {},
onAdClicked: () {},
onLeftApplication: () {},
onReturnedToApplication: () {},
onImpression: (String? impressionData) {},
);
SDK 6
Ad loading events arrive in the RewardedAdLoader object, while ad rendering events arrive in the RewardedAdEventListener object.
The RewardedAdEventListener object is set using the rewardedAd.setAdEventListener method.
Unified event names. Removed the onLeftApplication and onReturnedToApplication events.
Added the onAdFailedToShow event.
Renamed the onImpression event as onAdImpression.
RewardedAdLoader.create(
onAdLoaded: (RewardedAd rewardedAd) {},
onAdFailedToLoad: (error) {},
);
void _setAdEventListener(RewardedAd ad) {
ad.setAdEventListener(
eventListener: RewardedAdEventListener(
onAdShown: () {},
onAdFailedToShow: (AdError error) {},
onAdDismissed: () {},
onAdClicked: () {},
onAdImpression: (ImpressionData? data) {},
onRewarded: (Reward reward) {}
)
);
}
|
Interstitial ads
The approach to creating and loading advertisements has been revised. We now provide the InterstitialAdLoader loader object, which loads the ads, and the InterstitialAd ad object retrieved from the onAdLoaded ad load event.
|
Loading ads
|
SDK 5
One object is now used both for loading and serving ads:
final ad = await InterstitialAd.create(
adUnitId: 'your-ad-unit-id',
onAdLoaded: () {
},
onAdFailedToLoad: (error) {
},
);
await ad.load(adRequest: AdRequest());
SDK 6
InterstitialAdLoader loader object for loading multiple ads.
late final Future<InterstitialAdLoader> _adLoader =
_createInterstitialAdLoader();
InterstitialAd? _ad;
Future<InterstitialAdLoader> _createInterstitialAdLoader() {
return InterstitialAdLoader.create(
onAdLoaded: (InterstitialAd interstitialAd) {
_ad = interstitialAd;
},
onAdFailedToLoad: (error) {
},
);
}
Future<void> _loadInterstitialAd() async {
final adLoader = await _adLoader;
await adLoader.loadAd(adRequestConfiguration: AdRequestConfiguration(adUnitId: 'your-ad-unit-id'));
}
|
|
Ad serving
|
SDK 5
Check if the ad is loaded before displaying it.
InterstitialAd? _ad;
Future<void> _showInterstitialAd() async {
final ad = _ad;
if (ad != null && ad.isLoaded) {
await ad.show();
await ad.waitForDismiss();
}
}
SDK 6
You don't need to check whether the ad has been loaded. The ad is ready for rendering after it is returned by the onAdLoaded() callback method.
InterstitialAd? _ad;
Future<void> _showInterstitialAd() async {
final ad = _ad;
if (ad != null) {
_setAdEventListener(ad);
await ad.show();
await ad.waitForDismiss();
}
}
|
|
Subscribing to ad lifecycle events
|
SDK 5
All the events arrive in a single InterstitialAd object.
InterstitialAd.create(
onAdLoaded: () {},
onAdFailedToLoad: (AdLoadError error) {},
onAdShown: () {},
onAdDismissed: () {},
onAdClicked: () {},
onLeftApplication: () {},
onReturnedToApplication: () {},
onImpression: (String? impressionData) {},
);
SDK 6
Ad loading events arrive in the InterstitialAdLoader object, while ad rendering events arrive in the InterstitialAdEventListener object.
The InterstitialAdEventListener object is set using the interstitialAd.setAdEventListener method.
Unified event names. Removed the onLeftApplication and onReturnedToApplication events.
Added the onAdFailedToShow event.
Renamed the onImpression event as onAdImpression.
InterstitialAdLoader.create(
onAdLoaded: (InterstitialAd interstitialAd) {},
onAdFailedToLoad: (error) {},
);
void _setAdEventListener(InterstitialAd ad) {
ad.setAdEventListener(
eventListener: InterstitialAdEventListener(
onAdShown: () {},
onAdFailedToShow: (AdError error) {},
onAdDismissed: () {},
onAdClicked: () {},
onAdImpression: (ImpressionData? data) {}
)
);
}
|
App open ads
Added a new ad format: app open ads. You can learn more about it in the App open ads section.
You can view complete integration examples here:
Warning
Be sure to update to the latest adapter versions (Yandex Mediation). Otherwise, errors from improper adapter integration might occur, preventing the ad from being served.
Renamed the com.yandex.ads.mediation:mobileads-admob artifact as com.yandex.ads.mediation:mobileads-google.
If you use a unified mediation build, you do not need to do anything. If you add adapters individually, replace the gradle dependency in your project.
|
SDK 5
implementation 'com.yandex.ads.mediation:mobileads-admob:<version>'
|
SDK 6
implementation 'com.yandex.ads.mediation:mobileads-google:<version>'
|
We renamed the AdMobYandexMobileAdsAdapters adapters as GoogleYandexMobileAdsAdapters. If you use a unified mediation build, you do not need to do anything. If you add adapters individually, you need to edit your project's Podfile.
|
SDK 5
pod 'AdMobYandexMobileAdsAdapters'
|
SDK 6
pod 'GoogleYandexMobileAdsAdapters'
|