I am using Native Ads for my UWP app. The app works well with the test ad ids. However, when I put in real values for publishing (note the problem I am describing is for published app, and I downloaded the app from the Windows Store), it always returns NoAdAvailable
error:
private void LoadNativeAd(string adUnit, FrameworkElement adContainer)
{
var adsManager = new NativeAdsManagerV2(NativeAdAppId, adUnit);
adsManager.ErrorOccurred += this.AdsManager_ErrorOccurred;
adsManager.AdReady += (sender, e) =>
{
this.AdsManager_AdReady(adContainer, e);
};
adsManager.RequestAd();
}
private async void AdsManager_ErrorOccurred(object sender, NativeAdErrorEventArgs e)
{
var appFolder = ApplicationData.Current.LocalFolder;
var file = await appFolder.CreateFileAsync("ad.log", CreationCollisionOption.OpenIfExists);
using (var logStream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
using (var streamWriter = new StreamWriter(logStream.AsStreamForWrite()))
{
streamWriter.WriteLine($"{e.ErrorCode}: {e.ErrorMessage} ({e.RequestId})");
}
}
}
For testing value, AdsManager_AdReady
works well but with real value (either on local testing or real published app) it is never called. The content of the ad.log
file looks like this:
NoAdAvailable: No Ad Available (2ce6c6c3f848475f8dea0cc3cf2dba97)
The app/ad code is published for many weeks already. What's wrong with it?