AdMediator 允许为自家广告指定 0 权重(备份模式),在这种情况下(据我了解),自家广告仅在其他广告不可用时才会出现。在我的地方,它经常发生,看到一些东西而不是空白点真的很有意义。
我想使用来自 Store Services SDK 的 Microsoft AdMeditor 来实现这个想法。这就是我打算这样做的方式:
using MsAdControl = Microsoft.Advertising.WinRT.UI.AdControl;
......
private MsAdControl createMicrosoftAdControl() {
MsAdControl msAdControl = new MsAdControl();
msAdControl.AdRefreshed += OnMsAdRefreshed;
msAdControl.ErrorOccurred += OnMsBannerError;
msAdControl.ApplicationId = msBannerAppId;
msAdControl.AdUnitId = msBannerUintId;
msAdControl.AutoRefreshIntervalInSeconds = 30;
msAdControl.IsAutoRefreshEnabled = true;
......
return msAdControl;
}
// Callbacks
private void OnMsAdRefreshed(object sender, RoutedEventArgs e) {
var adControl = (MsAdControl)sender;
adControl.AdUnitId = msBannerUintId; // Revert to other ads
.......
}
private void OnMsBannerError(object sender, AdErrorEventArgs e) {
var adControl = (MsAdControl)sender;
if (adControl.AdUnitId != msBannerUintId)
adControl.AdUnitId = msBannerUintId; // Revert to other ads
else
if (e.ErrorCode == MsErrCode.NoAdAvailable) {
adControl.AdUnitId = msBannerHouseUintId; // Use house ads
adControl.Refresh();
}
.............
}
我收到错误代码 RefereshNotAllowed!
事实上,广告之间的最短超时时间为 30 秒是有道理的。但是,如果单位 ID 更改,则应将其重置!
我试图重新创建控制,希望这可以重置超时。没办法 - 看起来超时是静态处理的!
还有其他想法吗?