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

  • 相关阅读:
    8086汇编--1--通用寄存器和简单汇编指令
    写在前面的吐槽!
    汇编/Debug学习计划
    开篇-引文
    看懂别人的代码,和自己能写代码是两回事
    内存管理
    Flink基本原理及应用场景
    IDEA Maven Dependencies标红报错
    Spark Streaming流式处理
    Kafka
  • 原文地址:https://www.cnblogs.com/wgscd/p/13683713.html
Copyright © 2011-2022 走看看