Unter Github gibt es für Windows UWP
Apps das Store-Sample, mit welchem die Programmierung in der App von in-App
Käufen gezeigt wird.
Dabei gibt es mehrer Beispiel.
Folgende Möglichkeiten sind
üblicherweise wichtig:
· Trial
Mode
· In-App Purchase
· Consumable Product
· Rate this app
Trial Mode
Hier kann man prüfen, ob das Probe-Abo
noch gültig ist oder abgelaufen ist.
Man kann im Code per Lizenseinformation
prüfen ob man in der Testphase ist
LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;
if (licenseInformation.IsActive)
{
if (licenseInformation.IsTrial)
{
LicenseMode.Text = "Trial license";
}
else
{
LicenseMode.Text = "Full license";
}
}
else
{
LicenseMode.Text = "Inactive license";
}
|
In-App Purchase
Im Beispiel von 2) In-App Purchase kann
man prüfen, ob ein In-App Produkt gekauft wurde oder nicht.
Wie prüft man, ob ein App-In KaufProdukt
erworben wurde.
private void
TestProduct(string productId, string productName)
{
LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;
var productLicense = licenseInformation.ProductLicenses[productId];
if (productLicense.IsActive)
{
rootPage.NotifyUser("You can use " +
productName + ".", NotifyType.StatusMessage);
}
else
{
rootPage.NotifyUser("You don't own " +
productName + ".", NotifyType.ErrorMessage);
}
}
|
Consumable Product
Unter Consumable Products kann man im
Store verbrauchbare Pakete kaufen wie zum Beispiel Zusatzpunkte bei einem
Spiel.
Rate this
app
Die aktuelle App kann man bewerten mit:
await
Windows.System.Launcher.LaunchUriAsync(new Uri(CurrentAppSimulator.LinkUri.AbsoluteUri));
|
Store
Funktionen
Für die Programmierung und Verwendung der
Store-Funktionen muss zunächst der Namespace Store eingebunden werden
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Store;
using Windows.Storage;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using
Windows.UI.Xaml.Navigation;
|
AppSimulator.
Wichtig ist, dass alle Aufgaben am CurrentAppSimulator
durchgeführt werden