일반 변경 사항
MobileAds 클래스 이름이 YandexAds로 변경되었습니다.
다음 속성 및 메서드 이름이 변경되었습니다.
|
SDK 7
|
SDK 8
|
|
MobileAds.setLocationConsent(bool)
|
YandexAds.setLocationTracking(bool)
|
|
MobileAds.setAgeRestrictedUser(bool)
|
YandexAds.setAgeRestricted(bool)
|
광고 요청
AdRequestConfiguration 클래스가 제거되었습니다. 대신 adUnitId를 포함하는 AdRequest를 사용하세요.
타겟팅 필드(age, contextQuery, contextTags, gender, location)는 AdRequest에서 새 클래스 AdTargeting으로 옮겼습니다.
|
광고 요청
|
SDK 7
final adRequestConfiguration = AdRequestConfiguration(
adUnitId: 'your-ad-unit-id',
age: 25,
contextQuery: 'query',
parameters: {'key': 'value'},
);
await adLoader.loadAd(
adRequestConfiguration: adRequestConfiguration,
);
SDK 8
final adRequest = AdRequest(
adUnitId: 'your-ad-unit-id',
targeting: AdTargeting(
age: 25,
contextQuery: 'query',
),
parameters: {'key': 'value'},
);
final ad = await adLoader.loadAd(adRequest: adRequest);
|
전면 광고(전면, 보상형, 앱 열기)
전면 광고 생성 및 로딩 방식이 바뀌었습니다. 로더 생성자는 이제 동기식이며, loadAd는 로드된 광고를 Future로 직접 반환합니다.
InterstitialAdLoadListener, RewardedAdLoadListener, AppOpenAdLoadListener 클래스가 제거되었습니다.
|
광고 로딩
|
SDK 7
콜백을 사용한 비동기 생성:
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'));
}
SDK 8
동기 생성, loadAd는 로드된 광고를 반환하거나 AdRequestError를 던짐:
final _adLoader = InterstitialAdLoader();
InterstitialAd? _ad;
Future<void> _loadInterstitialAd() async {
try {
_ad = await _adLoader.loadAd(
adRequest: AdRequest(adUnitId: 'your-ad-unit-id'),
);
} on AdRequestError catch (error) {
}
}
|
동일한 변경이 RewardedAdLoader와 AppOpenAdLoader에도 적용됩니다.
배너
배너 광고 생성 및 로딩 방식이 바뀌었습니다. 배너 생성자는 더 이상 adRequest나 콜백을 받지 않습니다. 로딩은 이제 load(AdRequest)로 명시적으로 수행합니다. 광고 상태와 이벤트는 스트림으로 전달됩니다.
|
배너 생성 및 로딩
|
SDK 7
BannerAd? _banner;
void _createBanner() {
_banner = BannerAd(
adSize: BannerAdSize.stickySize(width),
adRequest: AdRequest(),
onAdLoaded: () {
},
onAdFailedToLoad: (error) {
},
onAdClicked: () {},
onImpression: (data) {},
);
}
SDK 8
BannerAd? _banner;
void _createBanner() {
final banner = BannerAd(adSize: BannerAdSize.stickySize(width));
banner.loadStateStream.listen((state) {
if (state is BannerAdLoadStateLoaded) {
} else if (state is BannerAdLoadStateError) {
}
});
banner.events.listen((event) {
if (event is BannerAdClickedEvent) {
} else if (event is BannerAdImpressionEvent) {
}
});
banner.load(AdRequest(adUnitId: 'your-ad-unit-id'));
_banner = banner;
}
|
|
배너 해제
|
SDK 7
SDK 8
await _banner?.destroy();
|
광고 정보
AdInfo 클래스 구조가 변경되었습니다. adSize 필드가 제거되었고, creatives, extraData, partnerText 필드가 추가되었습니다.
|
SDK 7
|
SDK 8
|
|
AdInfo.adSize
|
제거됨
|
|
—
|
AdInfo.creatives (List<Creative>)
|
|
—
|
AdInfo.extraData (String?)
|
|
—
|
AdInfo.partnerText (String?)
|
제거된 이벤트
onLeftApplication, onReturnedToApplication, onAdClose 콜백 이벤트가 제거되었습니다.