2016-03-07 64 views
2

我无法在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按预期显示广告(当然,这是另一回事!)。

我会尝试明天直接转移到我的手机,看看它是否让任何区别,我插上我的笔记本电脑的以太网端口,而不是使用无线的,但我的无线是相当不错的,所以我不知道为什么我会收到网络连接错误。

+0

请提供一些更多细节。详细信息 - 你如何实施InterstitialAd等 –

+0

@VineetChoudhary我已经添加了我使用的代码。希望这有助于找出问题。谢谢 – Thierry

+0

您是否尝试将断点放入'private void OnAdError(object sender,AdErrorEventArgs e)'方法中。这可能是由于在加载广告期间发生了一些错误。 –

回答

1

上面的代码是正确的,并没有实际上在Windows Phone UWP工作,但它不会在模拟器作为工作的伟大:

  • 它产生间歇性的网络连接错误时,他们没有。
  • 它可能需要一分钟才能显示广告,但它最终会。

我刚刚上传我的应用程序到商店,并将其下载到我的手机,并按预期工作。它会立即显示广告或在几秒钟内显示广告。

我建议你不要浪费太多时间通过电话模拟器尝试它,因为它似乎是主要问题。实施你的代码,然后直接在你的设备上测试它,或者从商店下载它,假设你还没有发布你的应用程序。

UPDATE:

我只是想我会更新我的答案,我只是念叨做的和不与来自UI and User Experience Guidelines间质性广告,我实际上做的方式,是点之一在“避免”列表中。

它建议您提前30-60秒提取广告,并且在应用程序启动时不显示它,这是我正在做的,所以我想我会改变这方面的逻辑。

+0

警告!提前提前发布广告可能会将您的应用列入买家列入黑名单(由于RTB市场的运作原因)。 60秒推动它。 – James

+0

@詹姆斯,刚才引用了MS在说什么,但是非常感谢分享这一点。我想,建议,最好使用默认值,即30秒。 – Thierry

+0

techqa.info,candoerz.com,还有......你还问过同样的问题吗? PS。我有同样的问题,但不是在模拟器中,而是在本地机器上......你认为问题出在广告服务器上吗? –