TheBlueSky TheBlueSky - 10 days ago 6
C# Question

AdDuplex Ad Control keeps showing despite collapsing it

I’m creating a WinRT (Windows 8.1 and Windows Phone 8.1) app in which I placed an AdDuplex ad control in one of its pages.

The user of the app can choose to remove the ad (with an IAP). When they do, I set the

Visibility
of the AdDuplex ad control to
Collapsed
, from the page ViewModel.

This part works fine; however, after some time, while the user is still on the page, AdDuplex ad control suddenly becomes visible again and starts showing ads.

At the beginning, I thought this is the behavior of IAP when using
CurrentAppSimulator
, although it didn’t make sense to me, since I have nothing in the code that reacts to license changes and hence setting the control back to
Visible
. Yet, I tested
license.IsActive
for my " NoAd” product and got
true
, indicating that the license is valid.

The following is a simplified part of my code:

MyPage.xaml

<ad:AdControl
AdUnitId="{StaticResource AdUnitId}"
AppKey="{StaticResource AdAppKey}"
IsTest="True"
CollapseOnError="True"
Visibility="{Binding IsNoAdPurchased, Converter={StaticResource BooleanToVisibilityInvertedConverter}}"/>


MyPageViewModel.cs

private async void RemoveAd()
{
this.IsNoAdPurchased = await this.storeService.PurchaseProductAsync(Products.NoAd);
}


StoreService.cs

#if DEBUG
using StoreCurrentApp = Windows.ApplicationModel.Store.CurrentAppSimulator;
#else
using StoreCurrentApp = Windows.ApplicationModel.Store.CurrentApp;
#endif

public sealed class StoreService
{
public async Task<bool> PurchaseProductAsync(string productId)
{
try
{
var purchase = await StoreCurrentApp.RequestProductPurchaseAsync(productId);
return purchase.Status == ProductPurchaseStatus.Succeeded || purchase.Status == ProductPurchaseStatus.AlreadyPurchased;
}
catch (Exception)
{
// The purchase did not complete because an error occurred.
return false;
}
}
}

Answer

This was an issue with AdDuplex Ad Control and was fixed in version 9.0.0.13.

Note: don't forget to set IsTest to false to see the "production" behaviour.

Comments