Projekt-Anfragen: Tel: 07022/9319004 info@CodeDocu.de Software Entwicklung in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

 

Folgendes Beispiel zeigt, wie man unter UWP die Anwendung prüfen kann auf getätigte Add-in Käufe.

 

Addin, Add-In Käufe

 

 

Video Anleitung in Deutsch-Englisch

 

C# Beispiel-Code mit Windows Services Store

using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using System.Runtime.InteropServices.WindowsRuntime;

using Windows.Foundation;

using Windows.Foundation.Collections;

using Windows.UI.Xaml;

using Windows.UI.Xaml.Controls;

using Windows.UI.Xaml.Controls.Primitives;

using Windows.UI.Xaml.Data;

using Windows.UI.Xaml.Input;

using Windows.UI.Xaml.Media;

using Windows.UI.Xaml.Navigation;

 

//< Namespaces >

using Windows.Services.Store;  //Store Add-ons Packages to buy

using System.Threading.Tasks;

//</ Namespaces >

 

namespace Check_InApp_Produkct_Status

{

 

    public sealed partial class MainPage : Page

    {

        public MainPage()

        {

            this.InitializeComponent();

        }

 

        #region Buttons

        //------------------< region: Buttons >------------------

        private void btnGet_Addins_Click(object sender, RoutedEventArgs e)

        {

            get_Store_LicenseInfo();

        }

 

        private void btnCheck_First_Addon_Click(object sender, RoutedEventArgs e)

        {

            check_First_AddOn_Package();

        }

        //------------------</ region: Buttons >------------------

        #endregion /Buttons

 

        #region Windows-Store

        //------------------< region: Windows-Store >------------------

        private StoreContext context = null;

        private StoreAppLicense appLicense = null;

 

        public async Task<bool> get_Store_LicenseInfo()

        {

            //-------------< get_Store_LicenseInfo()-------------

            if (context == null)

            {

                context = StoreContext.GetDefault();  //UWP App

            }

 

            workingProgressRing.IsActive = true;

           

            //< get Store Data >

            appLicense = await context.GetAppLicenseAsync();

            //</ get Store Data >

 

            workingProgressRing.IsActive = false;

 

            if (appLicense == null)

            {

                tbxStatus.Text = "An error occurred while retrieving the license.";

                return false ;

            }

            else

            {

                //--< show License Infos >--

                tbxStatus.Text = "APP-License" + Environment.NewLine + "SkuStoreId=" +  appLicense.SkuStoreId ;

                tbxStatus.Text += Environment.NewLine + "TrialUniqueId=" + Convert.ToString(appLicense.TrialUniqueId);

                tbxStatus.Text += Environment.NewLine + "IsActive=" + Convert.ToString(appLicense.IsActive );

                tbxStatus.Text += Environment.NewLine + "IsTrial="Convert.ToString( appLicense.IsTrial);

 

                tbxStatus.Text += Environment.NewLine + Environment.NewLine + "AddOnLicenses=" + Convert.ToString(appLicense.AddOnLicenses.Count);

                //--</ show License Infos >--

            }

 

            // Access the add on licenses for add-ons for this app.

            tbxStatus.Text += Environment.NewLine + "< addOn-Licenses>" + Environment.NewLine;

            foreach (KeyValuePair<string, StoreLicense> item in appLicense.AddOnLicenses)

            {

                StoreLicense addOnLicense = item.Value;

                //--< addon Purchase Infos  >--

                tbxStatus.Text = "addOn-License" + Environment.NewLine + "IsActive=" + addOnLicense.IsActive;

                tbxStatus.Text += Environment.NewLine + "SkuStoreId=" + Convert.ToString(addOnLicense.SkuStoreId );

                tbxStatus.Text += Environment.NewLine + "InAppOfferToken=" + Convert.ToString(addOnLicense.InAppOfferToken );

                tbxStatus.Text += Environment.NewLine + "ExpirationDate=" + Convert.ToString(addOnLicense.ExpirationDate );               

                //--</ addon Purchase Infos >--

            }

            tbxStatus.Text += "</ addOn-Licenses>" + Environment.NewLine;

            return true;

            //-------------</ get_Store_LicenseInfo()-------------

        }

 

 

        public async void check_First_AddOn_Package()

        {

            //-------------< check_First_AddOn_Package()-------------

            if (context == null)

            {

                await get_Store_LicenseInfo();

            }

 

           

            //< check >

            //</ check >

           

            if (appLicense == null)

            {

                tbxStatus.Text = "appLicense is null.";

                return;

            }

            else

            {

               

                tbxStatus.Text = "AddOnLicenses.Count=" + Convert.ToString(appLicense.AddOnLicenses.Count);

                //--</ show License Infos >--

            }

 

            tbxStatus.Text += Environment.NewLine + "< addOn-License 1 >" + Environment.NewLine;

            foreach (KeyValuePair<string, StoreLicense> item in appLicense.AddOnLicenses)

            {

                StoreLicense addOnLicense = item.Value;

                //--< addon Purchase Infos  >--

                tbxStatus.Text = "addOn-License" + Environment.NewLine + "IsActive=" + addOnLicense.IsActive;               

                break;

                //--</ addon Purchase Infos >--

            }

            tbxStatus.Text += "</ addOn-License 1 >" + Environment.NewLine;

            return ;

            //-------------</ check_First_AddOn_Package()-------------

        }

        //------------------</region: Windows-Store >------------------

        #endregion /Windows-Store

 

    }

}

 

 

 

XAML

 

Beispiel Xaml Code der Mainpage

<Page

    x:Class="Check_InApp_Produkct_Status.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:local="using:Check_InApp_Produkct_Status"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d">

 

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="180"/>

            <ColumnDefinition Width="63*"/>

        </Grid.ColumnDefinitions>

        <StackPanel Orientation="Vertical" >

            <Button  x:Name="btnGet_Addins" Click="btnGet_Addins_Click"

                     HorizontalAlignment="Left" Margin="10" VerticalAlignment="Top" Height="70" Width="160">

                Get License Infos

            </Button>

            <Button  x:Name="btnCheck_First_Addon" Click="btnCheck_First_Addon_Click"

                     HorizontalAlignment="Left" Margin="10" VerticalAlignment="Top" Height="70" Width="160">

                Check 1.Addon

            </Button>

           

            <ProgressRing x:Name="workingProgressRing" Height="100"  Width="100"></ProgressRing>

        </StackPanel>

       

        <Border Background="#F0F0F0" Grid.Column="1" Margin="20,20,20,20">

            <TextBlock x:Name="tbxStatus" HorizontalAlignment="Stretch"  TextWrapping="Wrap" Text="License Infos" VerticalAlignment="Stretch"  />

        </Border>

    </Grid>

</Page>

 

 

 

UWP: In App Käufe programmieren für Win32

 

Wenn man beabsichtigt, UWP Microsoft Store Apps zu entwickeln, welche teilweise auf einer Desktop Bridge Win32 beruhen,

dann kann man nur unter der Einbindung des Namespaces: Windows.Services.Store, welcher ab der Version Windows 10 Anniversary Update (10.0, Build 14393) ist.

Einstellen, dass die App mindestens unter Windowss 10 Version 1607 Anniversary Update Build 14393 läuft

 

Windows.Services.Store.StoreContext context = StoreContext.GetDefault();

 

 

Zum Testen während der Entwicklung soll man den CurrentAppSimulator  verwenden.

Vor dem Upload in den Windows Store muss der CurrentAppSimulator ersetzt werden durch CurrentApp:

 

Wofür benötigt man In-App Käufe?

Kostenlose Apps werden in der Regel häufiger Installiert als kostenpflichtige Anwendungen.

Deshalb ist es sinnvoll, Testversionen mit zusäztlichen Features auszustatten, welche den Funktionsumfang durch den Kauf der In-App Produkte und Funktionen erweitert.

 

 

Käufe mit dem Simulator führen nur zu einem lokalen Statusveränderung der App und werden zurückgesetzt beim Neustart.

 

Mobile
»
UWP: Prüfen und Abfragen von Addon-Käufen in einer Microsoft Store App
»
UWP: Store sample In App Käufe abfragen

.

Jobs, Projekte, Angebote für Freiberufler, Selbstständig an Info@CodeDocu.de