[英]Remove Ads (In-App Purchase) UWP App
我是一個簡單的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),可以刪除主頁上的廣告!
廣告和按鈕已刪除,但是當我導航到應用程序的另一個頁面或關閉並重新打開該應用程序時,該廣告會重新出現。
你能指望什么? 您僅在單擊按鈕時處理邏輯。 一旦加載了另一頁,邏輯就消失了。 您需要檢查並在每次加載頁面時查看ProductLicenses["RemoveAdsOffer"].IsActive
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.