删除广告(应用内购买)UWP应用

问题描述 投票:0回答:2

我是一个简单的uwp应用程序(在Microsoft/Windows Store中发布),我的主页上只有一个广告(横幅)。我想在用户进行应用内购买时删除广告。 我已经遵循了 Microsoft 和 Microsoft Virtual Academy 的教程,但我无法删除广告!

private async void removeAds_Click(object sender, RoutedEventArgs e)
        {
            if (!AppLicenseInformation.ProductLicenses["RemoveAdsOffer"].IsActive)
            {
                try
                {
                    // The customer doesn't own this feature, so 
                    // show the purchase dialog.

                    PurchaseResults results = await CurrentAppSimulator.RequestProductPurchaseAsync("RemoveAdsOffer");

                    //Check the license state to determine if the in-app purchase was successful.

                    if (results.Status == ProductPurchaseStatus.Succeeded)
                    {
                        removeAds.Visibility = Visibility.Collapsed;
                        Ad.Visibility = Visibility.Collapsed;
                    }
                }
                catch (Exception ex)
                {
                    // The in-app purchase was not completed because 
                    // an error occurred.
                    throw ex;
                }
            }
            else
            {
                // The customer already owns this feature.
            }
}

我有广告(Ad)和一个按钮(removeAds)来删除我主页上的广告!

广告和按钮已删除,但当我导航到应用程序的另一页面或关闭并重新打开应用程序时,广告会重新出现。

c# uwp windows-10 uwp-xaml
2个回答
0
投票

你期望什么?您只处理单击按钮时的逻辑。一旦加载另一个页面,逻辑就消失了。您需要检查每个页面是否加载

ProductLicenses["RemoveAdsOffer"].IsActive


0
投票

你能告诉我我到底该怎么做吗...?

© www.soinside.com 2019 - 2024. All rights reserved.