zoukankan      html  css  js  c++  java
  • UWP 检查是否试用版模式

    //老版本的方法:
             // var check=  CurrentAppSimulator.LicenseInformation.IsActive && CurrentAppSimulator.LicenseInformation.IsTrial;
            private StoreContext context = null;
            private StoreAppLicense appLicense = null;
    
            // Call this while your app is initializing.
            private async void InitializeLicense()
            {
                if (context == null)
                {
                    context = StoreContext.GetDefault();
                    // If your app is a desktop app that uses the Desktop Bridge, you
                    // may need additional code to configure the StoreContext object.
                    // For more info, see https://aka.ms/storecontext-for-desktop.
                }
    
                workingProgressRing.IsActive = true;
                appLicense = await context.GetAppLicenseAsync();
                workingProgressRing.IsActive = false;
    
                // Register for the licenced changed event.
                context.OfflineLicensesChanged += context_OfflineLicensesChanged;
    
              
                if ( appLicense.IsTrial)
                {
                    textBlock.Text = $"This is the trial version. Expiration date: {appLicense.ExpirationDate}";
    
                    // Show the features that are available during trial only.
                }
                else
                {
                    // Show the features that are available only with a full license.
                }
            }
    
            private async void context_OfflineLicensesChanged(StoreContext sender, object args)
            {
                // Reload the license.
                workingProgressRing.IsActive = true;
                appLicense = await context.GetAppLicenseAsync();
                workingProgressRing.IsActive = false;
    
                if (appLicense.IsActive)
                {
                    if (appLicense.IsTrial)
                    {
                        textBlock.Text = $"This is the trial version. Expiration date: {appLicense.ExpirationDate}";
    
                        // Show the features that are available during trial only.
                    }
                    else
                    {
                        // Show the features that are available only with a full license.
                    }
                }
            }
    

      

    参考官方:https://docs.microsoft.com/en-us/windows/uwp/monetize/in-app-purchases-and-trials#implement-trial

  • 相关阅读:
    SQL SERVER的检查点checkpoint
    MySQL备份说明
    声明对象和创建对象的区别
    getParameter的用法总结
    Jsp的九大对象,七大动作,三大指令
    为什么内部类访问的外部变量需要使用final修饰
    java synchronized详解
    网上选课系统需求说明书
    第三次作业
    第二次作业
  • 原文地址:https://www.cnblogs.com/wgscd/p/13683713.html
Copyright © 2011-2022 走看看