I'm using the Microsoft Advertising SDK for UWP: https://marketplace.visualstudio.com/items?itemName=AdMediator.MicrosoftAdvertisingSDK and want to add native ads to my App
Here is code that demonstrates the issue:
auto NativeAdManager = ref new Microsoft::Advertising::WinRT::UI::NativeAdsManager("d25517cb-12d4-4699-8bdc-52040c712cab", "10043134");
NativeAdManager->AdReady += ref new Windows::Foundation::EventHandler<Platform::Object^>([](Platform::Object ^ s, Platform::Object ^ ad)
{
Platform::String^ Title = static_cast<Microsoft::Advertising::WinRT::UI::NativeAd^>(ad)->Title;
Platform::String^ desc = static_cast<Microsoft::Advertising::WinRT::UI::NativeAd^>(ad)->Description;
__debugbreak();
});
NativeAdManager->ErrorOccurred += ref new Windows::Foundation::EventHandler<Microsoft::Advertising::WinRT::UI::AdErrorEventArgs^>([](Platform::Object^ sender, Microsoft::Advertising::WinRT::UI::AdErrorEventArgs^ e) {
auto x = e->ErrorMessage;
__debugbreak();
});
NativeAdManager->RequestAd();
Once RequestAd()
get's called, the AdReady
event handler run, as expected, but the problem is the ad data is nonsense. For example Title
is nullptr
, Description
is an invalid String handle, AdIcon
is an invalid image class, etc. The ErrorOccurred
event never fires. There's also some weird output in Visual Studio's debug output window:
info:get_AppId() invoked. [Windows::ApplicationModel::Store::CurrentAppFactory::get_AppId]
The thread 0x3ce0 has exited with code 0 (0x0).
ERROR:ChkHr(spStoreCommerce->Initialize(HStringReference(wszCV).Get())) (0x803f6107) [Windows::ApplicationModel::Store::CurrentAppFactory::GetStoreCommerce]
ERROR:ChkHr(GetStoreCommerce(&spStoreCommerce)) (0x803f6107) [Windows::ApplicationModel::Store::CurrentAppFactory::get_AppId]
info:GetAppReceiptAsync() invoked. [Windows::ApplicationModel::Store::CurrentAppFactory::GetAppReceiptAsync]
ERROR:ChkHr(spStoreCommerce->Initialize(HStringReference(wszCV).Get())) (0x803f6107) [Windows::ApplicationModel::Store::CurrentAppFactory::GetStoreCommerce]
ERROR:ChkHr(GetStoreCommerce(&spStoreCommerce)) (0x803f6107) [Windows::ApplicationModel::Store::CurrentAppFactory::GetAppReceiptAsync]
WLID Error: 80860003Exception thrown at 0x00007FFA59024008 in Advertising.exe: Microsoft C++ exception: Concurrency::task_canceled at memory location 0x00000064AFDFF228.
What am I doing wrong?