【问题标题】:InterstitialAd advert cancelled when requested - UWP - Windows 10请求时取消 InterstitialAd 广告 - UWP - Windows 10
【发布时间】:2016-04-03 11:59:06
【问题描述】:

我刚刚在我的 Microsoft Dev Dashboard 中创建了 2 个新的广告单元来处理 PC/平板电脑和移动设备上的 InterstitialAd

我首先初始化我的InterstitialAd

// Instantiate the interstitial video ad
interstitialAd = new InterstitialAd();

// Attach event handlers
interstitialAd.ErrorOccurred += OnAdError;
interstitialAd.AdReady += OnAdReady;
interstitialAd.Cancelled += OnAdCancelled;
interstitialAd.Completed += OnAdCompleted;

然后我得到以下代码来根据所使用的平台请求相关的InterstitialAd 广告:

#if DEBUG
    interstitialAd.RequestAd(AdType.Video, "d25517cb-12d4-4699-8bdc-52040c712cab", 
    "11389925");
    Debug.WriteLine("Page_Loaded - RequestAd: " + sw.Elapsed.ToString());
#else
    #if WINDOWS_PHONE_APP
        interstitialAd.RequestAd(AdType.Video, MAppId, MAdUnitId);
    #else
        interstitialAd.RequestAd(AdType.Video, WAppId, WAdUnitId);
    #endif
#endif 

Debug 模式下,它按预期工作,但在Release 模式下,第二个相关的interstitialAd.RequestAd 被调用,OnAdCancelled 方法被调用。

我已经仔细检查了与 MappIdMAdUnitIdWAppIdWAdUnitId 关联的值,它们都绝对正确,并且与所使用的正确平台相关联。

有什么想法吗??

谢谢。

【问题讨论】:

    标签: win-universal-app windows-10-universal


    【解决方案1】:

    这似乎是一个错误,如果您使用稍微复杂的条件语句,它会引发此错误。我不得不将我的代码更改为以下内容以消除此错误:

    var myAppId = "";
    var myAdUnitId = "";
    
    //Test Ids
    //myAppId = "d25517cb-12d4-4699-8bdc-52040c712cab";
    //myAdUnitId = "11389925";
    
    //Windows Store AppId;
    myAppId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
    myAdUnitId = "xxxxxxxx";
    
    #if WINDOWS_PHONE_APP
        myAppId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
        myAdUnitId = "xxxxxx";
    #endif
    
    interstitialAd.RequestAd(AdType.Video, myAppId, myAdUnitId);
    

    在这方面浪费了这么多时间后,我发现我所在的地区没有插页式广告。

    希望这对其他人有所帮助!

    【讨论】:

      猜你喜欢
      • 2017-10-06
      • 1970-01-01
      • 1970-01-01
      • 2016-06-10
      • 1970-01-01
      • 2017-02-17
      • 1970-01-01
      • 2017-03-26
      • 1970-01-01
      相关资源
      最近更新 更多