Reputation: 63
I am creating a UWP video editor application centered on the MediaComposition class and I want the user to play with and test it for as long as they want as they would be granted an unlimited free trial upon downloading and installing it. (The app will be made available through the Windows Store.) However, any videos produced will have a watermark. The watermark will be removed as soon as they purchase the app.
What API will raise a purchase event to help me accomplish this?
Upvotes: 0
Views: 125
Reputation: 117036
You may use the StoreContext.OfflineLicensesChanged
event from the Windows.Services.Store
to detect changes in your app's Microsoft Store license:
StoreContext.OfflineLicensesChanged
EventRaised when the status of the app's license changes (for example, the trial period has expired or the user has purchased the full version of the app).
public event TypedEventHandler<StoreContext,object> OfflineLicensesChanged;
When this event is raised, you can get the latest app license from the Microsoft Store by calling the
GetAppLicenseAsync
method. TheStoreAppLicense
object returned by this method also contains the latest add-on licenses for the app in theAddOnLicenses
property.
However, note the following version restriction:
The
Windows.Services.Store
namespace was introduced in Windows 10, version 1607, and it can only be used in projects that target Windows 10 Anniversary Edition (10.0; Build 14393) or a later release in Visual Studio. If your app targets an earlier version of Windows 10, you must use theWindows.ApplicationModel.Store
namespace instead of theWindows.Services.Store
namespace. For more information, see this article.
On earlier versions versions, the equivalent event is documented to be the LicenseChanged
event in the Windows.ApplicationModel.Store
namespace, which has the following additional remark:
LicenseChanged events aren't always immediate. If you’ve registered for the event, the event should fire within an hour; if not, it should occur within 6 hours. Generally, it's recommended to wait up to 6 hours when testing with
CurrentApp
, knowing that it will most likely take less time if the app has registered the event.
See also:
Upvotes: 1