none
请教如何实现应用程序试用或者购买呢? RRS feed

答案

  •         private async Task LoadTrialModeProxyFileAsync()
            {
                StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Data");
                StorageFile proxyFile = await proxyDataFolder.GetFileAsync("trial-mode.xml");
    
                licenseChangeHandler = new LicenseChangedEventHandler(TrialModeRefresh);
                CurrentAppSimulator.LicenseInformation.LicenseChanged += licenseChangeHandler;
    
                await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile);
                ListingInformation listing = await CurrentAppSimulator.LoadListingInformationAsync();
                
                Debug.WriteLine(listing.Name + listing.AgeRating + listing.FormattedPrice + listing.CurrentMarket + listing.ProductListings);
            }
    
            private void TrialModeRefresh()
            {
                LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;
                if (licenseInformation.IsActive)
                    if (licenseInformation.IsTrial)
                    {
                        int remainingTrialTime = (licenseInformation.ExpirationDate - DateTime.Now).Days;
    
                        Debug.WriteLine("Trial license. " + "You may use current App for " + remainingTrialTime + "Days");
                    }
                    else
                        Debug.WriteLine("Full license");
                else
                    Debug.WriteLine("Inactive license");
            }
    
            private async void GetFullLicense_Click(object sender, RoutedEventArgs e)
            {
                LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;
                if (licenseInformation.IsActive)
                    if (licenseInformation.IsTrial)
                    {
                        try
                        {
                            await CurrentAppSimulator.RequestAppPurchaseAsync(false);
                            if (!licenseInformation.IsTrial && licenseInformation.IsActive)
                                Debug.WriteLine("Geted Full license");
                            else
                                Debug.WriteLine("Trial license");
                        }
                        catch (Exception)
                        {
                            Debug.WriteLine("Get Full License Failed");
                        }
                    }
                    else
                        Debug.WriteLine("Full license");
                else
                    Debug.WriteLine("Inactive license");
            }

    Hello Wayne

    你可以使用上述示例代码来获取你试用的应用或者实现获取FullLicense来实现购买应用

    • 已标记为答案 Wayne1900 2013年1月18日 7:25
    2013年1月17日 12:51