我试图在调用事件时显示广告,使用以下代码:
using Microsoft.Advertising.WinRT.UI;
.
.
private InterstitialAd ad;
.
.
Interop.RequestInterstitialEvent += Interop_RequestInterstitialEvent;
Interop.ShowInterstitialEvent += Interop_ShowInterstitialEvent;
.
.
.
void Interop_RequestInterstitialEvent(object sender, EventArgs e)
{ //When I want to recharge ad
ad = new InterstitialAd();
ad.RequestAd(AdType.Video, "d25517cb-12d4-4699-8bdc-52040c712cab", "11389925");
}
void Interop_ShowInterstitialEvent(object sender, EventArgs e)
{ // Show your ad only if it is charging
if (ad.State == InterstitialAdState.Ready)
{
ad.Show();
}
}
确定何时在Ready
相同的工作后不久显示公告:
void Interop_RequestInterstitialEvent(object sender, EventArgs e)
{
ad = new InterstitialAd();
ad.RequestAd(AdType.Video, "d25517cb-12d4-4699-8bdc-52040c712cab", "11389925");
ad.AdReady += ad_AdReady;
}
void ad_AdReady(object sender, object e)
{
ad.Show();
}
但我想只在我致电Interop_ShowInterstitialEvent
时才显示它。如何在该事件中显示它?