Guide for migrating to version 8.0.0 (beta)
Unity Plugin 8.0.0 for Yandex Mobile Ads SDK introduces a number of API changes aimed at improving the developer experience.
Key changes
1. Changes to AdRequest
Removed the AdRequestConfiguration and AdRequest.Builder classes. The AdRequest builder now requires the adUnitId parameter. The Interstitial, Rewarded, and AppOpen builders now use AdRequest instead of AdRequestConfiguration.
| Class | Status |
|---|---|
AdRequestConfiguration |
Removed. Use AdRequest. |
AdRequest.Builder |
Removed. Use the AdRequest builder. |
Examples
C#
|
SDK 7 |
SDK 8 |
|
|
2. Changes to Targeting
Removed targeting fields (Age, Gender, Location, ContextQuery, ContextTags) from AdRequestConfiguration.Builder and AdRequest.Builder. Use the new AdTargeting class to manage targeting parameters.
| 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. Changes to ad loaders
Removed the OnAdLoaded and OnAdFailedToLoad events from RewardedAdLoader, InterstitialAdLoader, and AppOpenAdLoader. Loading results are now returned using callback parameters of the LoadAd method.
| 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 for InterstitialAdLoader (returns Interstitial) and AppOpenAdLoader (returns AppOpenAd).
3.1 Async/await support
Added async/await support in all ad loaders. AdLoadingException occurs in case of a loading error.
| 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. Changes to the Banner API
Removed the blockId parameter from the Banner builder. The ad unit ID is now passed in the AdRequest each time an ad is loaded. Renamed the BannerAdSize factory methods, removing the Size suffix.
| Class | SDK 7 | SDK 8 | Status |
|---|---|---|---|
banner |
Banner(blockId, adSize, position) |
Banner(adSize, position) |
Updated |
banner |
LoadAd(new AdRequest.Builder().Build()) |
LoadAd(new AdRequest(blockId)) |
Updated |
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. Renaming of the main SDK class
Renamed the MobileAds class 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. Changes to AdInfo
Removed the AdSize property from AdInfo. Added new properties: ExtraData, PartnerText, Creatives.
| Class | SDK 7 | SDK 8 | Status |
|---|---|---|---|
AdInfo |
AdUnitId |
AdUnitId |
No changes |
AdInfo |
AdSize |
— | Removed |
AdInfo |
— | ExtraData |
Added |
AdInfo |
— | PartnerText |
Added (only for Adfox) |
AdInfo |
— | Creatives |
Added |
Examples
C#
|
SDK 7 |
SDK 8 |
|
|
7. GetInfo() extension
The GetInfo() method is now available for all ad types, including AppOpenAd and Banner.
| Ad type | SDK 7 | SDK 8 | Status |
|---|---|---|---|
Interstitial.GetInfo() |
✓ | ✓ | No changes |
RewardedAd.GetInfo() |
✓ | ✓ | No changes |
AppOpenAd.GetInfo() |
— | ✓ | Added |
Banner.GetInfo() |
— | ✓ | Added |
Examples
C#
// SDK 8: GetInfo() is available for all ad types
AdInfo adInfo = banner.GetInfo();
if (adInfo != null)
{
Debug.Log($"AdUnitId: {adInfo.AdUnitId}");
}