我无法在Windows Phone Emulator上运行我的UWP应用程序时使用InterstitialAd
(请注意,我还没有在真实手机上试用过)InterstitialAd不能使用Windows Phone 10(UWP - Windows 10)
当我在模拟器或本地计算机上将我的UWP应用程序作为Windows应用商店应用运行时,它的工作方式与预期的相同。
任何想法?
谢谢。
UPDATE - 1
这里是我使用显示在InterstitialAd的代码。在我MainPage.xaml.cs中,我有以下代码:
public sealed partial class MainPage : Page
{
private InterstitialAd interstitialAd;
public MainPage()
{
this.InitializeComponent();
// Instantiate the interstitial video ad
interstitialAd = new InterstitialAd();
// Attach event handlers
interstitialAd.ErrorOccurred += OnAdError;
interstitialAd.AdReady += OnAdReady;
interstitialAd.Cancelled += OnAdCancelled;
interstitialAd.Completed += OnAdCompleted;
}
}
// This is an event handler for the interstitial ad. It is
// triggered when the interstitial ad is ready to play.
private void OnAdReady(object sender, object e)
{
// The ad is ready to show; show it.
interstitialAd.Show();
}
// This is an event handler for the interstitial ad. It is
// triggered when the interstitial ad is cancelled.
private void OnAdCancelled(object sender, object e)
{
}
// This is an event handler for the interstitial ad. It is
// triggered when the interstitial ad has completed playback.
private void OnAdCompleted(object sender, object e)
{
}
// This is an error handler for the interstitial ad.
private void OnAdError(object sender, AdErrorEventArgs e)
{
}
我文采采取了这种代码从他们UWP Store示例不同之处在于不是从按钮启动此,我启动它时,我的网页加载:
private void Page_Loaded(object sender, RoutedEventArgs e)
{
// Request an ad. When the ad is ready to show,
// the AdReady event will fire.
// The application id and ad unit id are passed in here.
// The application id and ad unit id can be obtained from Dev
// Center.
// See "Monetize with Ads" at https://msdn.microsoft.com/
// en-us/library/windows/apps/mt170658.aspx
#if DEBUG
interstitialAd.RequestAd(AdType.Video,
"d25517cb-12d4-4699-8bdc-52040c712cab", "11389925");
#else
interstitialAd.RequestAd(AdType.Video,
"d25517cb-12d4-4699-8bdc-52040c712cab", "11389925");
#endif
}
我已经离开了这两个的applicationID和UnitAdId作为暂时我还没有它尚未公布,好了,不会与广告反正测试值。
感谢
更新 - 2:
我已经在各种活动中加入一些调试日志,这是我得到:
Page_Loaded: 00:00:00.0001590
Page_Loaded - RequestAd: 00:00:00.0091840
OnAdReady - Elasped Time: 00:01:04.6923865
OnAdError: NetworkConnectionFailure : Media timeout occurred
during playback. - Elasped
Time: 00:00:08.1955928
它接管了1分钟该OnAdReady被触发,这真的很奇怪,然后我得到一个OnAdError8秒后,所以从这些日志中,你会认为有一个网络问题,但我的数据正在正确加载,这是从一个Web服务,所以肯定有联系。此外,我的AdMediator按预期显示广告(当然,这是另一回事!)。
我会尝试明天直接转移到我的手机,看看它是否让任何区别,我插上我的笔记本电脑的以太网端口,而不是使用无线的,但我的无线是相当不错的,所以我不知道为什么我会收到网络连接错误。
请提供一些更多细节。详细信息 - 你如何实施InterstitialAd等 –
@VineetChoudhary我已经添加了我使用的代码。希望这有助于找出问题。谢谢 – Thierry
您是否尝试将断点放入'private void OnAdError(object sender,AdErrorEventArgs e)'方法中。这可能是由于在加载广告期间发生了一些错误。 –