none
Windows应用试用期问题 RRS feed

  • 问题

  • 我的一个Windows应用商店应用,上传应用商店时,设定7天试用期。朋友下载安装后,当时显示“试用期还剩 6 天”。两天后运程程序,还是显示“试用期还剩 6 天”,不知问题出在哪里?

    主要代码如下:
            protected override   void OnNavigatedTo(NavigationEventArgs e)
            {
                //打开程序时,检查程序许可,试用版是否到期 
                TrialModeRefreshScenario();
                //客户购买后,检查程序许可
                licenseChangeHandler = new LicenseChangedEventHandler(TrialModeRefreshScenario);
                CurrentApp.LicenseInformation.LicenseChanged += licenseChangeHandler;
            }

            private async  void TrialModeRefreshScenario()
            {
                LicenseInformation licenseInformation = CurrentApp.LicenseInformation;           
                if (licenseInformation.IsActive)
                {
                    if (licenseInformation.IsTrial)
                    {
                        var remainingTrialTime = (licenseInformation.ExpirationDate - DateTime.Now).Days;
                        txtblkTryDays.Text = "试用期还剩 " + remainingTrialTime + " 天。";
                         //以下代码省略
                    }
                    else
                    {
                         //以下代码省略
                    }
                }
                else
                {
                       //以下代码省略
                }
            }

    以下这个代码计算有问题吗?
    var remainingTrialTime = (licenseInformation.ExpirationDate - DateTime.Now).Days;

    licenseInformation.ExpirationDate这个过期日期是怎么生成的?存储在哪里?

    请高明予以解答。多谢。

    2014年3月28日 2:08

答案

  • Hi,

    您在上传您的app到windows 应用商店时会选择试用的期限,有一天、七天等等,那么这个ExpirationDate是根据您选择的试用时间长度得到的,比如说用户某天下载了您的app,如果您的app试用期是7天的话,那么您的ExpirationDate是该用户下载的时间往后推迟7天。您的代码看来是正确的,建议您在本地根据CurrentAppSimulator 类 ,然后配置如下的xml文档,放置于  %userprofile%\appdata\local\packages\<package-moniker>\localstate\microsoft\Windows Store\Apidata 文件夹中的 WindowsStoreProxy.xml 中来进行测试下您的代码:

    <?xml version="1.0" encoding="UTF-16"?>
    <CurrentApp>
      <ListingInformation>
        <App>
          <AppId>2B14D306-D8F8-4066-A45B-0FB3464C67F2</AppId>
          <LinkUri>http://apps.windows.microsoft.com/app/2B14D306-D8F8-4066-A45B-0FB3464C67F2</LinkUri>
          <CurrentMarket>en-US</CurrentMarket>
          <AgeRating>3</AgeRating>
          <MarketData xml:lang="en-us">
            <Name>Trial management full license</Name>
            <Description>Sample app for demonstrating trial license management</Description>
            <Price>4.99</Price>
            <CurrencySymbol>$</CurrencySymbol>
          </MarketData>
        </App>
      </ListingInformation>
      <LicenseInformation>
        <App>
          <IsActive>true</IsActive>
          <IsTrial>true</IsTrial>
          <ExpirationDate>此处改成过期的日期</ExpirationDate>
        </App>
      </LicenseInformation>
      <Simulation SimulationMode="Automatic">
        <DefaultResponse MethodName="LoadListingInformationAsync_GetResult" HResult="E_FAIL"/>
      </Simulation>
    </CurrentApp>

    具体参考以下链接:

    http://msdn.microsoft.com/en-us/library/windows/apps/dn532253.aspx

    祝您好运!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2014年3月31日 6:37
    版主