none
Do I need to cache the In-App purchases in Windows Phone 8? RRS feed

  • Question

  • Do I need to cache the fact of having a license of In-App purchase? The user there may be no internet connection for example. I do not want check the license on each application start up, with the method.

    await CurrentApp.LoadListingInformationAsync();

    Is there a need to cache In-App purchase in IsolatedStorage? For example:

     /// <summary>
        /// Get list of In-app purchased
        /// </summary>
        /// <returns></returns>
        public async Task<List<string>> GetOwnedItems()
        {
            var settings = IsolatedStorageSettings.ApplicationSettings;
    
            List<string> items = (List<string>)settings["PurchasedProducts"];
    
            if (!items.Any()) //TODO If no purchases, call this block one time, no more!!!
            {
                ListingInformation li = await CurrentApp.LoadListingInformationAsync();
                items = new List<string>();
    
                foreach (string key in li.ProductListings.Keys)
                {
                    if (CurrentApp.LicenseInformation.ProductLicenses[key].IsActive)
                        items.Add(key);
                }
    
               //Save to IsolatedStorage
               settings["PurchasedProducts"] = items;
            }
    
            return items;
        }
    
        public async void PurcaseItem(string itemKey)
        {
            if (!Store.CurrentApp.LicenseInformation.ProductLicenses[itemKey].IsActive)
            {
                ListingInformation li = await Store.CurrentApp.LoadListingInformationAsync();
                string pID = li.ProductListings[itemKey].ProductId;
    
                string receipt = await Store.CurrentApp.RequestProductPurchaseAsync(pID, false);
    
                var settings = IsolatedStorageSettings.ApplicationSettings;
    
                //TODO Add key to Isolated storage
                List<string> items = ((List<string>)settings["PurchasedProducts"]).Add(pID);
    
            }
        }


    flanker

    Saturday, October 12, 2013 3:23 PM

Answers