Guide for migrating to version 8
Yandex Mobile Ads Unity plugin 8.0.0 changes several APIs to improve the developer experience.
Main changes
1. AdRequest changes
AdRequestConfiguration and AdRequest.Builder are removed. adUnitId is a required AdRequest constructor argument. AdRequest is now used for Interstitial, Rewarded, and AppOpen loaders instead of AdRequestConfiguration.
| Class | Status |
|---|---|
AdRequestConfiguration |
Removed. Use AdRequest |
AdRequest.Builder |
Removed. Use the AdRequest constructor |
Examples
C#
|
SDK 7 |
SDK 8 |
|
|
2. Targeting changes
Targeting fields (Age, Gender, Location, ContextQuery, ContextTags) are removed from AdRequestConfiguration.Builder and AdRequest.Builder. Use the new AdTargeting class.
| Class | Property | Status |
|---|---|---|
AdRequestConfiguration.Builder |
WithAge |
Removed. Use AdTargeting(age:) |
AdRequestConfiguration.Builder |
WithGender |
Removed. Use AdTargeting(gender:) |
AdRequestConfiguration.Builder |
WithLocation |
Removed. Use AdTargeting(location:) |
AdRequestConfiguration.Builder |
WithContextQuery |
Removed. Use AdTargeting(contextQuery:) |
AdRequestConfiguration.Builder |
WithContextTags |
Removed. Use AdTargeting(contextTags:) |
AdRequest.Builder |
WithAge |
Removed. Use AdTargeting(age:) |
AdRequest.Builder |
WithGender |
Removed. Use AdTargeting(gender:) |
AdRequest.Builder |
WithLocation |
Removed. Use AdTargeting(location:) |
AdRequest.Builder |
WithContextQuery |
Removed. Use AdTargeting(contextQuery:) |
AdRequest.Builder |
WithContextTags |
Removed. Use AdTargeting(contextTags:) |
AdTargeting |
— | Added |
Examples
C#
|
SDK 7 |
SDK 8 |
|
|
3. Ad loader changes
OnAdLoaded and OnAdFailedToLoad are removed from RewardedAdLoader, InterstitialAdLoader, and AppOpenAdLoader. Load results are delivered via LoadAd callback parameters.
| Class | Loader | Status |
|---|---|---|
AppOpenAdLoader |
LoadAd(request) + OnAdLoaded, OnAdFailedToLoad |
Replaced with LoadAd(request, onLoaded, onFailed) |
InterstitialAdLoader |
LoadAd(request) + OnAdLoaded, OnAdFailedToLoad |
Replaced with LoadAd(request, onLoaded, onFailed) |
RewardedAdLoader |
LoadAd(request) + OnAdLoaded, OnAdFailedToLoad |
Replaced with LoadAd(request, onLoaded, onFailed) |
OnAdLoaded |
— | Removed |
OnAdFailedToLoad |
— | Removed |
Examples
C#
|
SDK 7 |
SDK 8 |
|
|
The same pattern applies to InterstitialAdLoader (returns Interstitial) and AppOpenAdLoader (returns AppOpenAd).
3.1 Async/await support
All ad loaders support async/await. Failed loads throw AdLoadingException.
| Loader | Method | Status |
|---|---|---|
AppOpenAdLoader |
LoadAd(request) |
Added |
InterstitialAdLoader |
LoadAd(request) |
Added |
RewardedAdLoader |
LoadAd(request) |
Added |
Examples
C#
var loader = new RewardedAdLoader();
try
{
_rewardedAd = await loader.LoadAd(new AdRequest("R-M-XXXXX-YY"));
}
catch (AdLoadingException e)
{
Debug.Log(e.Message);
}
4. Banner API changes
The blockId constructor argument is removed from Banner. The ad unit ID is passed via AdRequest on each load. BannerAdSize factory methods drop the Size suffix.
| Class | SDK 7 | SDK 8 | Status |
|---|---|---|---|
Banner |
Banner(blockId, adSize, position) |
Banner(adSize, position) |
Changed |
Banner |
LoadAd(new AdRequest.Builder().Build()) |
LoadAd(new AdRequest(blockId)) |
Changed |
BannerAdSize |
FixedSize(width, height) |
Fixed(width, height) |
Renamed |
BannerAdSize |
StickySize(width) |
Sticky(width) |
Renamed |
BannerAdSize |
InlineSize(width, maxHeight) |
Inline(width, maxHeight) |
Renamed |
Examples
C#
|
SDK 7 |
SDK 8 |
|
|
5. Main SDK class rename
MobileAds is renamed to YandexAds.
| SDK 7 | SDK 8 | Status |
|---|---|---|
MobileAds |
YandexAds |
Renamed |
MobileAds.SetUserConsent(consent) |
YandexAds.SetUserConsent(consent) |
Renamed |
MobileAds.SetLocationTracking(enabled) |
YandexAds.SetLocationTracking(enabled) |
Renamed |
MobileAds.SetAgeRestricted(restricted) |
YandexAds.SetAgeRestricted(restricted) |
Renamed |
MobileAds.ShowDebugPanel() |
YandexAds.ShowDebugPanel() |
Renamed |
Examples
C#
|
SDK 7 |
SDK 8 |
|
|
6. AdInfo changes
AdSize is removed from AdInfo. New properties: ExtraData, PartnerText, Creatives.
| Class | SDK 7 | SDK 8 | Status |
|---|---|---|---|
AdInfo |
AdUnitId |
AdUnitId |
Unchanged |
AdInfo |
AdSize |
— | Removed |
AdInfo |
— | ExtraData |
Added |
AdInfo |
— | PartnerText |
Added (ADFOX only) |
AdInfo |
— | Creatives |
Added |
Examples
C#
|
SDK 7 |
SDK 8 |
|
|
7. GetInfo() availability
GetInfo() is available for all ad types, including AppOpenAd and Banner.
| Ad type | SDK 7 | SDK 8 | Status |
|---|---|---|---|
Interstitial.GetInfo() |
✓ | ✓ | Unchanged |
RewardedAd.GetInfo() |
✓ | ✓ | Unchanged |
AppOpenAd.GetInfo() |
— | ✓ | Added |
Banner.GetInfo() |
— | ✓ | Added |
Examples
C#
// SDK 8: GetInfo() for all ad types
AdInfo adInfo = banner.GetInfo();
if (adInfo != null)
{
Debug.Log($"AdUnitId: {adInfo.AdUnitId}");
}