横幅广告
将 AdSize 类重命名为 BannerAdSize。 移除了 flexibleSize(int width, int maxHeight) 方法。
根据广告类型使用方法:
要创建自适应粘性横幅,请使用 BannerAdSize.stickySize(int width) 方法。
自适应固定横幅广告是一种小型广告,会自动更新,并显示在应用屏幕的顶部或底部。
它不会遮挡主要内容,常用于游戏应用中。
粘性横幅的高度是自动确定的,可根据设备屏幕尺寸调整,并且不超过屏幕高度的 15%。
重要
从 6.0.0 版本开始,自适应粘性横幅支持自动刷新。
如果您之前已为粘性横幅实施了自动刷新,请禁用它。
要创建自适应内联横幅,请使用 BannerAdSize.inlineSize(int width, int maxHeight) 方法。
自适应内嵌横幅广告是一种灵活的横幅广告格式,通过针对每台设备优化广告尺寸,确保投放效果达到最优。
横幅高度是自动选择的,并且可以达到设备屏幕的高度。
通常,这种格式用于基于信息流的应用或可以将用户注意力主要集中在广告上的上下文环境中。
激励广告
我们改变了创建和加载广告的方法。 我们现在提供 RewardedAdLoader 加载器对象,用于加载广告,以及从 onAdLoaded 广告加载事件检索的 RewardedAd 广告对象。
|
加载广告
|
SDK 5
现在使用一个对象同时进行广告加载和投放:
final ad = await RewardedAd.create(
adUnitId: 'your-ad-unit-id',
onAdLoaded: () {
},
onAdFailedToLoad: (error) {
},
);
await ad.load(adRequest: AdRequest());
SDK 6
用于加载多个广告的 RewardedAdLoader。
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'));
}
|
|
广告展示成功
|
SDK 5
请在显示广告前检查广告是否已加载。
RewardedAd? _ad;
Future<void> _showRewardedAd() async {
final ad = _ad;
if (ad != null && ad.isLoaded) {
await ad.show();
var reward = await ad.waitForDismiss();
}
}
SDK 6
您无需检查广告是否已加载。 广告在通过 onAdLoaded() 回调方法返回后,准备好进行呈现。
RewardedAd? _ad;
Future<void> _showRewardedAd() async {
final ad = _ad;
if (ad != null) {
_setAdEventListener(ad);
await ad.show();
var reward = await ad.waitForDismiss();
}
}
|
|
订阅广告生命周期事件
|
SDK 5
所有事件均到达单个 RewardedAd 对象。
RewardedAd.create(
onAdLoaded: () {},
onAdFailedToLoad: (AdLoadError error) {},
onAdShown: () {},
onAdDismissed: () {},
onRewarded: (Reward reward) {},
onAdClicked: () {},
onLeftApplication: () {},
onReturnedToApplication: () {},
onImpression: (String? impressionData) {},
);
SDK 6
广告加载事件到达 RewardedAdLoader 对象,而广告呈现事件到达 RewardedAdEventListener 对象。
使用 rewardedAd.setAdEventListener 方法设置 RewardedAdEventListener 对象。
统一的事件名称。 移除了 onLeftApplication 和 onReturnedToApplication 事件。
添加了 onAdFailedToShow 事件。
将 onImpression 事件重命名为 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) {}
)
);
}
|
插屏广告
我们改变了创建和加载广告的方法。 我们现在提供 InterstitialAdLoader 加载器对象,用于加载广告,以及从 onAdLoaded 广告加载事件检索的 InterstitialAd 广告对象。
|
加载广告
|
SDK 5
现在使用一个对象同时进行广告加载和投放:
final ad = await InterstitialAd.create(
adUnitId: 'your-ad-unit-id',
onAdLoaded: () {
},
onAdFailedToLoad: (error) {
},
);
await ad.load(adRequest: AdRequest());
SDK 6
用于加载多个广告的 InterstitialAdLoader。
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 5
请在显示广告前检查广告是否已加载。
InterstitialAd? _ad;
Future<void> _showInterstitialAd() async {
final ad = _ad;
if (ad != null && ad.isLoaded) {
await ad.show();
await ad.waitForDismiss();
}
}
SDK 6
您无需检查广告是否已加载。 广告在通过 onAdLoaded() 回调方法返回后,准备好进行呈现。
InterstitialAd? _ad;
Future<void> _showInterstitialAd() async {
final ad = _ad;
if (ad != null) {
_setAdEventListener(ad);
await ad.show();
await ad.waitForDismiss();
}
}
|
|
订阅广告生命周期事件
|
SDK 5
所有事件均到达单个 InterstitialAd 对象。
InterstitialAd.create(
onAdLoaded: () {},
onAdFailedToLoad: (AdLoadError error) {},
onAdShown: () {},
onAdDismissed: () {},
onAdClicked: () {},
onLeftApplication: () {},
onReturnedToApplication: () {},
onImpression: (String? impressionData) {},
);
SDK 6
广告加载事件到达 InterstitialAdLoader 对象,而广告呈现事件到达 InterstitialAdEventListener 对象。
使用 interstitialAd.setAdEventListener 方法设置 InterstitialAdEventListener 对象。
统一的事件名称。 移除了 onLeftApplication 和 onReturnedToApplication 事件。
添加了 onAdFailedToShow 事件。
将 onImpression 事件重命名为 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) {}
)
);
}
|
开屏广告
添加了新的广告格式:开屏广告。 您可以在开屏广告部分了解更多信息。
您可以在此处查看完整的集成示例:
将 com.yandex.ads.mediation:mobileads-admob 构件重命名为 com.yandex.ads.mediation:mobileads-google。
如果您使用标准化聚合构建,则无需执行任何操作。 如果单独添加适配器,请替换项目中的 gradle 依赖项。
|
SDK 5
implementation 'com.yandex.ads.mediation:mobileads-admob:<version>'
|
SDK 6
implementation 'com.yandex.ads.mediation:mobileads-google:<version>'
|
我们将 AdMobYandexMobileAdsAdapters 适配器重命名为 GoogleYandexMobileAdsAdapters。 如果您使用标准化聚合构建,则无需执行任何操作。 如果单独添加适配器,则需要编辑项目的 Podfile。
|
SDK 5
pod 'AdMobYandexMobileAdsAdapters'
|
SDK 6
pod 'GoogleYandexMobileAdsAdapters'
|