StoreContext.GetAppLicenseAsync() returns false for active subscription in MSIX CLI
I'm building a WinRT CLI wrapper in C# that checks if a user owns an active Microsoft Store subscription add-on. This CLI is called from an Electron + React.js app using command-line arguments and returns true
or false
depending on the license status.
The Problem
The CheckSubscription <AddonId>
command incorrectly returns false
, even though the logged-in user does have an active subscription to the add-on.
I ran the application within these conditions:
- MSIX-packaged CLI app (Windows 10+)
- Published to Microsoft Store (delisted for testing)
- Using
StoreContext.GetAppLicenseAsync()
- Subscription add-on is published and testable
- The add-on ID resolves correctly via the API
I have also confirmed that my app does indeed receive a list of addons that a user has a liscence to sometimes.
Below is the Code Snippet
private static async Task HandleCheckSubscriptionCommand(string[] args)
{
string addonId = args[1];
var context = StoreContext.GetDefault();
var license = await context.GetAppLicenseAsync();
foreach (var kvp in license.AddOnLicenses)
{
var addOnLicense = kvp.Value;
if (addOnLicense.SkuStoreId.Equals(addonId, StringComparison.OrdinalIgnoreCase))
{
bool isValid = addOnLicense.IsActive && addOnLicense.ExpirationDate > DateTimeOffset.UtcNow;
Console.WriteLine(isValid ? "true" : "false");
return;
}
}
Console.WriteLine("false");
}
What can I do to resolve this issue?