Thierry
Thierry

Reputation: 6458

InterstitialAd advert cancelled when requested - UWP - Windows 10

I've just created 2 new Ad Units in my Microsoft Dev Dashboard to handle InterstitialAdon both PC/Tablets and Mobile.

I initialize my InterstitialAd first:

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

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

Then I've got the following code to request the relevant InterstitialAd advert based on the platform being used:

#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 

It works as expected when in Debug mode, but when in Release mode, the second the relevant interstitialAd.RequestAd is called, the OnAdCancelled method is called.

I've double checked the values associated with MappId, MAdUnitId, WAppId and WAdUnitId and they all are definitely correct and associated with the correct platform being used.

Any ideas??

Thanks.

Upvotes: 0

Views: 130

Answers (1)

Thierry
Thierry

Reputation: 6458

This appears to be a bug where if you use slightly more complex conditional statements, it throws this error. I had to change my code to the following to get rid of this error:

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);

And after having wasted so much time on this, I found out that there is no Interstitial Advert in my region.

Hope this helps others!

Upvotes: 0

Related Questions