StoreContext StoreContext StoreContext StoreContext Class

Definition

Provides members you can use to access and manage Microsoft Store-related data for the current app. For example, you can use members of this class to get Microsoft Store listing and license info for the current app, purchase the current app or products that are offered by the app, or download and install package updates for the app.

public : sealed class StoreContext : IStoreContext, IStoreContext2
public sealed class StoreContext : IStoreContext, IStoreContext2
Public NotInheritable Class StoreContext Implements IStoreContext, IStoreContext2
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Services.Store.StoreContract (introduced v1)

Remarks

Note

This class and the rest of the Windows.Services.Store namespace was introduced in Windows 10, version 1607. This class 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 project targets an earlier version of Windows 10, you must use the Windows.ApplicationModel.Store namespace instead of the Windows.Services.Store namespace. For more information, see In-app purchases and trials.

The StoreContext class is the main entry point to the Windows.Services.Store namespace. Use members of this class to perform tasks such as getting Microsoft Store listing and license info for the current app, purchasing the current app or add-ons that are offered by the app, or downloading and installing package updates for the app. Other classes and types in this namespace represent items such as add-ons for the app, licenses for the app and its add-ons, and Microsoft Store listing info for the app.

To get a StoreContext object, use one of these static methods:

  • GetDefault: Use this method in single-user apps (that is, apps that run only in the context of the user that launched the app). This method gets a StoreContext object that you can use to access and manage Microsoft Store-related data for the user. Most Universal Windows Platform (UWP) apps are single-user apps.

    Windows.Services.Store.StoreContext context = StoreContext.GetDefault();
    
  • GetForUser: Use this method in multi-user apps. This method gets a StoreContext object that you can use to access and manage Microsoft Store-related data for a specific user. For more information about multi-user apps, see Introduction to multi-user applications.

    var users = await Windows.System.User.FindAllAsync();
    Windows.Services.Store.StoreContext context = StoreContext.GetForUser(users[0]);
    

Note

In a Windows desktop application that uses the Desktop Bridge, you must add some additional code to configure the StoreContext object before your app can use this object. For more information, see Using the StoreContext class in a desktop application that uses the Desktop Bridge.

After you have a StoreContext object, you can start calling methods to purchase an app or add-on for the current user and other tasks. For more information, see the following articles:

You can also use a StoreContext object to download and install package updates for the app. For more information, see Download and install package updates for your app.

Properties

User User User User

Gets an object that provides info about the current user.

public : User User { get; }
public User User { get; }
Public ReadOnly Property User As User
var user = storeContext.user;
Value
User User User User

An object that provides info about the current user

Methods

AcquireStoreLicenseForOptionalPackageAsync(Package) AcquireStoreLicenseForOptionalPackageAsync(Package) AcquireStoreLicenseForOptionalPackageAsync(Package) AcquireStoreLicenseForOptionalPackageAsync(Package)

Acquires a license for the specified downloadable content (DLC) package for the current app.

public : IAsyncOperation<StoreAcquireLicenseResult> AcquireStoreLicenseForOptionalPackageAsync(Package optionalPackage)
public IAsyncOperation<StoreAcquireLicenseResult> AcquireStoreLicenseForOptionalPackageAsync(Package optionalPackage)
Public Function AcquireStoreLicenseForOptionalPackageAsync(optionalPackage As Package) As IAsyncOperation( Of StoreAcquireLicenseResult )
var iAsyncOperation = storeContext.acquireStoreLicenseForOptionalPackageAsync(optionalPackage);
Parameters
optionalPackage
Package Package Package Package

The DLC package for which to acquire a license.

Returns

Remarks

Note

Downloadable content (DLC) packages are not available to all developer accounts.

FindStoreProductForPackageAsync(IIterable, Package) FindStoreProductForPackageAsync(IIterable, Package) FindStoreProductForPackageAsync(IIterable, Package) FindStoreProductForPackageAsync(IIterable, Package)

Gets Store product details for the app or add-on that is associated with the specified package.

public : IAsyncOperation<StoreProductResult> FindStoreProductForPackageAsync(IIterable<Platform::String> productKinds, Package package)
public IAsyncOperation<StoreProductResult> FindStoreProductForPackageAsync(IEnumerable<String> productKinds, Package package)
Public Function FindStoreProductForPackageAsync(productKinds As IEnumerable<String>, package As Package) As IAsyncOperation( Of StoreProductResult )
var iAsyncOperation = storeContext.findStoreProductForPackageAsync(productKinds, package);
Parameters
productKinds
IIterable<Platform::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

An array of strings that specify the types of Store products that might be associated with the package. For a list of the supported string values, see the ProductKind property.

package
Package Package Package Package

A Package that represents the package for which you want to get the corresponding Store product details.

Returns

An asynchronous operation that, on successful completion, returns a StoreProductResult object. Use the Product property of this object to access a StoreProduct that contains Store product details for the specified package.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Services.Store.StoreContract (introduced v2)

Remarks

Use this method to get Store product details (such as the Store ID) for a package that is associated with the current app or an add-on for the current app. This method may return errors if the package is not associated with the current app, the current device is offline, or if the current app was not installed from the Store (for example, if the app was sideloaded). In these cases, you can examine the ExtendedError property of the StoreProductResult return object to get more details about the error.

See Also

GetAppAndOptionalStorePackageUpdatesAsync() GetAppAndOptionalStorePackageUpdatesAsync() GetAppAndOptionalStorePackageUpdatesAsync() GetAppAndOptionalStorePackageUpdatesAsync()

Gets the collection of packages for the current app that have updates available for download from the Microsoft Store, including optional packages for the app (also called downloadable content or DLC).

public : IAsyncOperation<IVectorView<StorePackageUpdate>> GetAppAndOptionalStorePackageUpdatesAsync()
public IAsyncOperation<IReadOnlyList<StorePackageUpdate>> GetAppAndOptionalStorePackageUpdatesAsync()
Public Function GetAppAndOptionalStorePackageUpdatesAsync() As IAsyncOperation<IReadOnlyList<StorePackageUpdate>>( Of IVectorView )
var iAsyncOperation = storeContext.getAppAndOptionalStorePackageUpdatesAsync();
Returns
IAsyncOperation<IVectorView<StorePackageUpdate>> IAsyncOperation<IReadOnlyList<StorePackageUpdate>> IAsyncOperation<IReadOnlyList<StorePackageUpdate>> IAsyncOperation<IReadOnlyList<StorePackageUpdate>>

An asynchronous operation that, on successful completion, returns a collection of StorePackageUpdate objects that represent the packages that have updates available.

Remarks

For more information about using this method, including a code example, see Download and install package updates for your app.

There is a latency of up to a day between the time when a package passes the certification process and when the GetAppAndOptionalStorePackageUpdatesAsync method recognizes that the package update is available to the app.

After you call GetAppAndOptionalStorePackageUpdatesAsync to determine which packages have updates available, you can call RequestDownloadStorePackageUpdatesAsync to download the updated packages or you can call RequestDownloadAndInstallStorePackageUpdatesAsync to download and install the updated packages.

Important

Downloadable content (DLC) packages are not available to all developer accounts.

See Also

GetAppLicenseAsync() GetAppLicenseAsync() GetAppLicenseAsync() GetAppLicenseAsync()

Gets license info for the current app, including licenses for add-ons for the current app.

public : IAsyncOperation<StoreAppLicense> GetAppLicenseAsync()
public IAsyncOperation<StoreAppLicense> GetAppLicenseAsync()
Public Function GetAppLicenseAsync() As IAsyncOperation( Of StoreAppLicense )
var iAsyncOperation = storeContext.getAppLicenseAsync();
Returns

An asynchronous operation that, on successful completion, returns a StoreAppLicense object that contains license info for the current app, including add-on licenses.

Remarks

The StoreAppLicense object returned by this method provides access to licenses for add-ons and other info, such as whether the license is active. If this method is called while the device is offline, it returns the cached value of the current licenses on the device. The OfflineLicensesChanged event is raised when the status of the app's license changes.

For more information about using this method, including code examples, see Get license info for apps and add-ons and Implement a trial version of your app.

See Also

GetAssociatedStoreProductsAsync(IIterable) GetAssociatedStoreProductsAsync(IIterable) GetAssociatedStoreProductsAsync(IIterable) GetAssociatedStoreProductsAsync(IIterable)

Gets Microsoft Store listing info for the products that can be purchased from within the current app.

public : IAsyncOperation<StoreProductQueryResult> GetAssociatedStoreProductsAsync(IIterable<Platform::String> productKinds)
public IAsyncOperation<StoreProductQueryResult> GetAssociatedStoreProductsAsync(IEnumerable<String> productKinds)
Public Function GetAssociatedStoreProductsAsync(productKinds As IEnumerable<String>) As IAsyncOperation( Of StoreProductQueryResult )
var iAsyncOperation = storeContext.getAssociatedStoreProductsAsync(productKinds);
Parameters
productKinds
IIterable<Platform::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

An array of strings that specify the types of products you want to get. For a list of the supported string values, see the ProductKind property.

Returns

An asynchronous operation that, on successful completion, returns a StoreProductQueryResult that provides access to the associated products and relevant error info.

Remarks

For more information about using this method, including a code example, see Get product info for apps and add-ons.

See Also

GetAssociatedStoreProductsWithPagingAsync(IIterable, UInt32) GetAssociatedStoreProductsWithPagingAsync(IIterable, UInt32) GetAssociatedStoreProductsWithPagingAsync(IIterable, UInt32) GetAssociatedStoreProductsWithPagingAsync(IIterable, UInt32)

Gets Microsoft Store listing info for the products that can be purchased from within the current app. This method supports paging to return the results.

public : IAsyncOperation<StoreProductPagedQueryResult> GetAssociatedStoreProductsWithPagingAsync(IIterable<Platform::String> productKinds, unsigned int maxItemsToRetrievePerPage)
public IAsyncOperation<StoreProductPagedQueryResult> GetAssociatedStoreProductsWithPagingAsync(IEnumerable<String> productKinds, UInt32 maxItemsToRetrievePerPage)
Public Function GetAssociatedStoreProductsWithPagingAsync(productKinds As IEnumerable<String>, maxItemsToRetrievePerPage As UInt32) As IAsyncOperation( Of StoreProductPagedQueryResult )
var iAsyncOperation = storeContext.getAssociatedStoreProductsWithPagingAsync(productKinds, maxItemsToRetrievePerPage);
Parameters
productKinds
IIterable<Platform::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

An array of strings that specify the types of products you want to get. For a list of the supported string values, see the ProductKind property.

maxItemsToRetrievePerPage
unsigned int UInt32 UInt32 UInt32

The maximum number of products to return in each page of results.

Returns

An asynchronous operation that, on successful completion, returns a StoreProductPagedQueryResult that provides access to the associated products, relevant error info, and the next page of results.

Remarks

This method is similar to GetAssociatedStoreProductsAsync, with the difference that it enables you to use paging to retrieve the products. For more information about using GetAssociatedStoreProductsAsync, including a code example, see Get product info for apps and add-ons.

Use the HasMoreResults of the StoreProductPagedQueryResult return value to determine whether there are additional pages of results, and use the GetNextAsync method to get the next page of results.

Note

Always use HasMoreResults to determine if there are more pages available, even if the current page of data contains fewer items than maxItemsToRetrievePerPage. To provide faster results, the service can return fewer items in a page than maxItemsToRetrievePerPage even if there are more pages of data available.

GetConsumableBalanceRemainingAsync(String) GetConsumableBalanceRemainingAsync(String) GetConsumableBalanceRemainingAsync(String) GetConsumableBalanceRemainingAsync(String)

Gets the remaining balance for the specified consumable add-on for the current app.

public : IAsyncOperation<StoreConsumableResult> GetConsumableBalanceRemainingAsync(Platform::String productStoreId)
public IAsyncOperation<StoreConsumableResult> GetConsumableBalanceRemainingAsync(String productStoreId)
Public Function GetConsumableBalanceRemainingAsync(productStoreId As String) As IAsyncOperation( Of StoreConsumableResult )
var iAsyncOperation = storeContext.getConsumableBalanceRemainingAsync(productStoreId);
Parameters
productStoreId
Platform::String String String String

The Store ID for the add-on (as provided by the StoreId property of the StoreProduct that represents the add-on).

Returns

An asynchronous operation that, on successful completion, returns a StoreConsumableResult that provides the remaining balance and other info.

Remarks

For more information about using this method, including a code example, see Enable consumable add-on purchases.

See Also

GetCustomerCollectionsIdAsync(String, String) GetCustomerCollectionsIdAsync(String, String) GetCustomerCollectionsIdAsync(String, String) GetCustomerCollectionsIdAsync(String, String)

Retrieves a Microsoft Store collections ID key that can be used to query for product entitlements or to consume product entitlements that are owned by the current user.

public : IAsyncOperation<Platform::String> GetCustomerCollectionsIdAsync(Platform::String serviceTicket, Platform::String publisherUserId)
public IAsyncOperation<string> GetCustomerCollectionsIdAsync(String serviceTicket, String publisherUserId)
Public Function GetCustomerCollectionsIdAsync(serviceTicket As String, publisherUserId As String) As IAsyncOperation( Of string )
var iAsyncOperation = storeContext.getCustomerCollectionsIdAsync(serviceTicket, publisherUserId);
Parameters
serviceTicket
Platform::String String String String

An Azure Active Directory access token that identifies the publisher of the current app. For more information about generating this token, see Manage product entitlements from a service.

publisherUserId
Platform::String String String String

An anonymous ID that identifies the current user in the context of services that are managed by the publisher of the current app. If the publisher maintains anonymous user IDs for use in their services, they can use this parameter to correlate these user IDs with the calls they make to Microsoft Store services. This parameter is optional.

Returns

An asynchronous operation that, on successful completion, returns the collections ID key for the current user. This key is valid for 90 days.

Remarks

Publishers with catalogs of in-app purchases can use the collections ID key in service-to-service calls to the Microsoft Store collections API to query for product entitlements or to consume product entitlements that are owned by the current user. An entitlement represents the customer's right to use an app or add-on that is published through the Microsoft Store. For more information, see Manage product entitlements from a service.

See Also

GetCustomerPurchaseIdAsync(String, String) GetCustomerPurchaseIdAsync(String, String) GetCustomerPurchaseIdAsync(String, String) GetCustomerPurchaseIdAsync(String, String)

Retrieves a Microsoft Store purchase ID key that can be used to grant entitlements for free products on behalf of the current user.

public : IAsyncOperation<Platform::String> GetCustomerPurchaseIdAsync(Platform::String serviceTicket, Platform::String publisherUserId)
public IAsyncOperation<string> GetCustomerPurchaseIdAsync(String serviceTicket, String publisherUserId)
Public Function GetCustomerPurchaseIdAsync(serviceTicket As String, publisherUserId As String) As IAsyncOperation( Of string )
var iAsyncOperation = storeContext.getCustomerPurchaseIdAsync(serviceTicket, publisherUserId);
Parameters
serviceTicket
Platform::String String String String

An Azure Active Directory access token that identifies the publisher of the current app. For more information about generating this token, see Manage product entitlements from a service.

publisherUserId
Platform::String String String String

An anonymous ID that identifies the current user in the context of services that are managed by the publisher of the current app. If the publisher maintains anonymous user IDs for use in their services, they can use this parameter to correlate these user IDs with the calls they make to Microsoft Store services. This parameter is optional.

Returns

An asynchronous operation that, on successful completion, returns the purchase ID key for the current user. This key is valid for 90 days.

Remarks

Publishers with catalogs of in-app purchases can use the collections ID key in service-to-service calls to the Microsoft Store purchase API to grant entitlements for free products on behalf of the current user. An entitlement represents the customer's right to use an app or add-on that is published through the Microsoft Store. For more information, see Manage product entitlements from a service.

See Also

GetDefault() GetDefault() GetDefault() GetDefault()

Gets a StoreContext object that can be used to access and manage Microsoft Store-related data for the current user in the context of the current app.

public : static StoreContext GetDefault()
public static StoreContext GetDefault()
Public Static Function GetDefault() As StoreContext
var storeContext = Windows.Services.Store.StoreContext.getDefault();
Returns

An object that you can use to access and manage Microsoft Store-related data for the current user.

Remarks

If your app is a single-user app (that is, it runs only in the context of the user that launched the app), use the GetDefault method to get a StoreContext object that you can use to access and manage Microsoft Store-related data for the user. Most Universal Windows Platform (UWP) apps are single-user apps. For more information about this method, see In-app purchases and trials.

If your app is a multi-user app, use the GetForUser method to get a StoreContext object for a specific user.

See Also

GetForUser(User) GetForUser(User) GetForUser(User) GetForUser(User)

Gets a StoreContext object that can be used to access and manage Microsoft Store-related data for the specified user in the context of the current app.

public : static StoreContext GetForUser(User user)
public static StoreContext GetForUser(User user)
Public Static Function GetForUser(user As User) As StoreContext
var storeContext = Windows.Services.Store.StoreContext.getForUser(user);
Parameters
user
User User User User

An object that identifies the user whose Microsoft Store-related data you want to access and manage.

Returns

An object that you can use to access and manage Microsoft Store-related data for the specified user.

Remarks

If your app is a multi-user app, use the GetForUser method to get a StoreContext object that you can use to access and manage Microsoft Store-related data for a specific user who is signed in with their Microsoft account while using the app. For more information about this method, see In-app purchases and trials. For more information about multi-user apps, see Introduction to multi-user applications.

If your app is a single-user app (that is, it runs only in the context of the user that launched the app), use the GetDefault method to get a StoreContext object for the current user. Most Universal Windows Platform (UWP) apps are single-user apps.

See Also

GetStoreProductForCurrentAppAsync() GetStoreProductForCurrentAppAsync() GetStoreProductForCurrentAppAsync() GetStoreProductForCurrentAppAsync()

Gets Microsoft Store listing info for the current app and provides access to a method that you can use to purchase the app for the current user.

public : IAsyncOperation<StoreProductResult> GetStoreProductForCurrentAppAsync()
public IAsyncOperation<StoreProductResult> GetStoreProductForCurrentAppAsync()
Public Function GetStoreProductForCurrentAppAsync() As IAsyncOperation( Of StoreProductResult )
var iAsyncOperation = storeContext.getStoreProductForCurrentAppAsync();
Returns

An asynchronous operation that, on successful completion, returns a StoreProductResult object that contains Microsoft Store listing info for the current app and any relevant error info.

Remarks

For more information about using this method, including a code example, see Get product info for apps and add-ons.

See Also

GetStoreProductsAsync(IIterable, IIterable) GetStoreProductsAsync(IIterable, IIterable) GetStoreProductsAsync(IIterable, IIterable) GetStoreProductsAsync(IIterable, IIterable)

Gets Microsoft Store listing info for the specified products that are associated with the current app.

public : IAsyncOperation<StoreProductQueryResult> GetStoreProductsAsync(IIterable<Platform::String> productKinds, IIterable<Platform::String> storeIds)
public IAsyncOperation<StoreProductQueryResult> GetStoreProductsAsync(IEnumerable<String> productKinds, IEnumerable<String> storeIds)
Public Function GetStoreProductsAsync(productKinds As IEnumerable<String>, storeIds As IEnumerable<String>) As IAsyncOperation( Of StoreProductQueryResult )
var iAsyncOperation = storeContext.getStoreProductsAsync(productKinds, storeIds);
Parameters
productKinds
IIterable<Platform::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

An array of strings that specify the types of products for which you want to retrieve listing info. For a list of the supported string values, see the ProductKind property.

storeIds
IIterable<Platform::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

An array of the Store ID strings for the products for which you want to retrieve listing info.

Returns

An asynchronous operation that, on successful completion, returns a StoreProductQueryResult object that contains listing info for the specified products and any relevant error info.

Remarks

This method returns listing info for the specified products that are associated with the current app, regardless of whether the products are currently available for purchase within the current app. To retrieve info for all the products that can currently be purchased from within the current app, use the GetAssociatedStoreProductsAsync method instead.

The Store ID for a product is available in the Windows Dev Center dashboard, and it also is returned by the StoreId property of the StoreProduct that represents the product. For more information, see Store IDs.

For more information about using this method, including a code example, see Get product info for apps and add-ons.

See Also

GetUserCollectionAsync(IIterable) GetUserCollectionAsync(IIterable) GetUserCollectionAsync(IIterable) GetUserCollectionAsync(IIterable)

Gets Microsoft Store info for the add-ons of the current app for which the user has entitlements to use.

public : IAsyncOperation<StoreProductQueryResult> GetUserCollectionAsync(IIterable<Platform::String> productKinds)
public IAsyncOperation<StoreProductQueryResult> GetUserCollectionAsync(IEnumerable<String> productKinds)
Public Function GetUserCollectionAsync(productKinds As IEnumerable<String>) As IAsyncOperation( Of StoreProductQueryResult )
var iAsyncOperation = storeContext.getUserCollectionAsync(productKinds);
Parameters
productKinds
IIterable<Platform::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

An array of strings that specify the types of add-ons for which you want to retrieve listing info. For a list of the supported string values, see the ProductKind property.

Returns

An asynchronous operation that, on successful completion, returns a StoreProductQueryResult object that contains Microsoft Store listing info for the add-ons of the current app for which the user has entitlements to use.

Remarks

For more information about using this method, including a code example, see Get product info for apps and add-ons.

See Also

GetUserCollectionWithPagingAsync(IIterable, UInt32) GetUserCollectionWithPagingAsync(IIterable, UInt32) GetUserCollectionWithPagingAsync(IIterable, UInt32) GetUserCollectionWithPagingAsync(IIterable, UInt32)

Gets Microsoft Store info for the add-ons of the current app for which the user has entitlements to use. This method supports paging to return the results.

public : IAsyncOperation<StoreProductPagedQueryResult> GetUserCollectionWithPagingAsync(IIterable<Platform::String> productKinds, unsigned int maxItemsToRetrievePerPage)
public IAsyncOperation<StoreProductPagedQueryResult> GetUserCollectionWithPagingAsync(IEnumerable<String> productKinds, UInt32 maxItemsToRetrievePerPage)
Public Function GetUserCollectionWithPagingAsync(productKinds As IEnumerable<String>, maxItemsToRetrievePerPage As UInt32) As IAsyncOperation( Of StoreProductPagedQueryResult )
var iAsyncOperation = storeContext.getUserCollectionWithPagingAsync(productKinds, maxItemsToRetrievePerPage);
Parameters
productKinds
IIterable<Platform::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

An array of strings that specify the types of add-ons for which you want to retrieve listing info. For a list of the supported string values, see the ProductKind property.

maxItemsToRetrievePerPage
unsigned int UInt32 UInt32 UInt32

The maximum number of add-ons to return in each page of results.

Returns

An asynchronous operation that, on successful completion, returns a StoreProductPagedQueryResult object that provides access to the Microsoft Store listing info for the add-ons of the current app for which the user has entitlements to use, as well as the next page of results.

Remarks

This method is similar to GetUserCollectionAsync, with the difference that it enables you to use paging to retrieve the add-ons. For more information about using GetUserCollectionAsync, including a code example, see Get product info for apps and add-ons.

Use the HasMoreResults of the StoreProductPagedQueryResult object to determine whether there are additional pages of results, and use the GetNextAsync method to get the next page of results.

Note

Always use HasMoreResults to determine if there are more pages available, even if the current page of data contains fewer items than maxItemsToRetrievePerPage. To provide faster results, the service can return fewer items in a page than maxItemsToRetrievePerPage even if there are more pages of data available.

ReportConsumableFulfillmentAsync(String, UInt32, Guid) ReportConsumableFulfillmentAsync(String, UInt32, Guid) ReportConsumableFulfillmentAsync(String, UInt32, Guid) ReportConsumableFulfillmentAsync(String, UInt32, Guid)

Reports a consumable add-on for the current app as fulfilled in the Microsoft Store.

public : IAsyncOperation<StoreConsumableResult> ReportConsumableFulfillmentAsync(Platform::String productStoreId, unsigned int quantity, Platform::Guid trackingId)
public IAsyncOperation<StoreConsumableResult> ReportConsumableFulfillmentAsync(String productStoreId, UInt32 quantity, Guid trackingId)
Public Function ReportConsumableFulfillmentAsync(productStoreId As String, quantity As UInt32, trackingId As Guid) As IAsyncOperation( Of StoreConsumableResult )
var iAsyncOperation = storeContext.reportConsumableFulfillmentAsync(productStoreId, quantity, trackingId);
Parameters
productStoreId
Platform::String String String String

The Store ID of the consumable add-on that you want to report as fulfilled.

quantity
unsigned int UInt32 UInt32 UInt32

The number of units of the consumable add-on that you want to report as fulfilled. For a Store-managed consumable (that is, a consumable where Microsoft keeps track of the balance), specify the number of units that have been consumed. For a developer-managed consumable (that is, a consumable where the developer keeps track of the balance), specify 1.

trackingId
Platform::Guid Guid Guid Guid

A developer-supplied GUID that identifies the specific transaction that the fulfillment operation is associated with for tracking purposes. For more information, see the remarks.

Returns

An asynchronous operation that, on successful completion, returns a StoreConsumableResult object that contains info about the fulfillment operation, such as the remaining balance of add-on units.

Remarks

After the user has used a consumable add-on in your app, use this method to report the add-on as fulfilled in the Microsoft Store. The Store ID for the add-on is available in the Windows Dev Center dashboard, and it is returned by the StoreId property of the StoreProduct that represents the add-on. For more information about using this method, including a code example, see Enable consumable add-on purchases.

The trackingId parameter is used to help ensure that each fulfillment operation is handled exactly once by the Microsoft Store. For example, consider a scenario where you call ReportConsumableFulfillmentAsync with a given pair of productStoreId and trackingId values, the Microsoft Store successfully marks the consumable as fulfilled, but there is a network connectivity issue that prevents your app from receiving and handling the response. The next time your app retries the same ReportConsumableFulfillmentAsync call with the same pair of productStoreId and trackingId values after it regains connectivity, the Microsoft Store will report the transaction as successful without charging the user again. The trackingId parameter can be retrieved via the TrackingId property of the StoreConsumableResult return value.

See Also

RequestDownloadAndInstallStorePackagesAsync(IIterable) RequestDownloadAndInstallStorePackagesAsync(IIterable) RequestDownloadAndInstallStorePackagesAsync(IIterable) RequestDownloadAndInstallStorePackagesAsync(IIterable)

Downloads and installs the specified downloadable content (DLC) packages for the current app from the Microsoft Store.

Important

This method must be called on the UI thread.

public : IAsyncOperationWithProgress<StorePackageUpdateResult, StorePackageUpdateStatus> RequestDownloadAndInstallStorePackagesAsync(IIterable<Platform::String> storeIds)
public IAsyncOperationWithProgress<StorePackageUpdateResult, StorePackageUpdateStatus> RequestDownloadAndInstallStorePackagesAsync(IEnumerable<String> storeIds)
Public Function RequestDownloadAndInstallStorePackagesAsync(storeIds As IEnumerable<String>) As IAsyncOperationWithProgress( Of StorePackageUpdateResult )( Of StorePackageUpdateStatus )
var iAsyncOperationWithProgress = storeContext.requestDownloadAndInstallStorePackagesAsync(storeIds);
Parameters
storeIds
IIterable<Platform::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

The product IDs of the add-on packages to install.

Returns
Exceptions
COMException COMException COMException COMException

If the ErrorCode property of the exception has the value 0x80070578 (ERROR_INVALID_WINDOW_HANDLE), this indicates that the method was not called on the UI thread. If you are calling this method in a desktop application that uses the Desktop Bridge, this can also indicate that you did not configure the StoreContext object to specify which application window is the owner window for modal dialogs shown by this method. For more information, see this article.

Remarks

Use this method to download and install a new DLC package for the current app.

This operation will not block. The IAsyncOperationWithProgress object returned by this method will complete after the packages are downloaded and installed.

When you call this method, the OS displays a dialog that tells the user that an app package is available to download and install, and asks the user's permission to proceed with the operation. If the user does not grant permission, the OverallState property of the StorePackageUpdateResult return value has the value Canceled.

The method that you assign to handle Progress notifications is called one time for each step in the download and installation process for each package in this request. The Progress handler receives a StorePackageUpdateStatus argument that provides info about the package that raised the progress notification.

Note

Downloadable content (DLC) packages are not available to all developer accounts.

RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable) RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable) RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable) RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable)

Downloads and installs the specified package updates for the current app from the Microsoft Store.

Important

This method must be called on the UI thread.

public : IAsyncOperationWithProgress<StorePackageUpdateResult, StorePackageUpdateStatus> RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate> storePackageUpdates)
public IAsyncOperationWithProgress<StorePackageUpdateResult, StorePackageUpdateStatus> RequestDownloadAndInstallStorePackageUpdatesAsync(IEnumerable<StorePackageUpdate> storePackageUpdates)
Public Function RequestDownloadAndInstallStorePackageUpdatesAsync(storePackageUpdates As IEnumerable<StorePackageUpdate>) As IAsyncOperationWithProgress( Of StorePackageUpdateResult )( Of StorePackageUpdateStatus )
var iAsyncOperationWithProgress = storeContext.requestDownloadAndInstallStorePackageUpdatesAsync(storePackageUpdates);
Parameters
storePackageUpdates
IIterable<StorePackageUpdate> IEnumerable<StorePackageUpdate> IEnumerable<StorePackageUpdate> IEnumerable<StorePackageUpdate>

The set of StorePackageUpdate objects that represent the updated packages to download and install.

Returns
Exceptions
COMException COMException COMException COMException

If the ErrorCode property of the exception has the value 0x80070578 (ERROR_INVALID_WINDOW_HANDLE), this indicates that the method was not called on the UI thread. If you are calling this method in a desktop application that uses the Desktop Bridge, this can also indicate that you did not configure the StoreContext object to specify which application window is the owner window for modal dialogs shown by this method. For more information, see this article.

Remarks

To get the list of packages that have updates available, use the GetAppAndOptionalStorePackageUpdatesAsync method. If you download a package update by using the RequestDownloadStorePackageUpdatesAsync method before calling RequestDownloadAndInstallStorePackageUpdatesAsync, this method will install the package update without trying to download it again. For more information about using this method, including a code example, see Download and install package updates for your app.

This operation will not block. The IAsyncOperationWithProgress object returned by this method will complete after the update packages are downloaded and installed.

When you call this method, the OS displays the following UI:

  • The OS displays a dialog that tells the user that an app update is available to download and asks the user's permission to proceed with the download. If the user does not grant permission to start the download, the OverallState property of the StorePackageUpdateResult return value has the value Canceled.

  • After the updated packages are downloaded, the OS displays another dialog that tells the user that the app update is waiting to be installed and asks the user's permission to proceed with the installation. This dialog warns the user that the app might need to restart. If the user does not grant permission to start the installation, the OverallState property of the StorePackageUpdateResult return value has the value Canceled.

Display progress info for the download and install

The method that you assign to handle Progress notifications is called one time for each step in the download and installation process for each package in this request. The Progress handler receives a StorePackageUpdateStatus argument that provides info about the update package that raised the progress notification.

If you want to show a custom progress UI (such as a ProgressBar) that provides status to the user, you can use the PackageDownloadProgress field of the StorePackageUpdateStatus argument to get the current progress of each package download and install operation, represented by a value from 0.0 to 1.0. This value increases from 0.0 to 0.8 during the download, and then it increases from 0.8 to 1.0 during the install.

Therefore, if you map the percentage shown in your custom progress UI directly to the value of the PackageDownloadProgress field, be aware that your UI will show 80% when the package is finished downloading and the OS displays the installation dialog. If you want your custom progress UI to display 100% when the package is downloaded and ready to be installed, you can modify your code to assign 100% to your progress UI when the PackageDownloadProgress field reaches 0.8.

See Also

RequestDownloadStorePackageUpdatesAsync(IIterable) RequestDownloadStorePackageUpdatesAsync(IIterable) RequestDownloadStorePackageUpdatesAsync(IIterable) RequestDownloadStorePackageUpdatesAsync(IIterable)

Downloads the specified package updates for the current app from the Microsoft Store.

Important

This method must be called on the UI thread.

public : IAsyncOperationWithProgress<StorePackageUpdateResult, StorePackageUpdateStatus> RequestDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate> storePackageUpdates)
public IAsyncOperationWithProgress<StorePackageUpdateResult, StorePackageUpdateStatus> RequestDownloadStorePackageUpdatesAsync(IEnumerable<StorePackageUpdate> storePackageUpdates)
Public Function RequestDownloadStorePackageUpdatesAsync(storePackageUpdates As IEnumerable<StorePackageUpdate>) As IAsyncOperationWithProgress( Of StorePackageUpdateResult )( Of StorePackageUpdateStatus )
var iAsyncOperationWithProgress = storeContext.requestDownloadStorePackageUpdatesAsync(storePackageUpdates);
Parameters
storePackageUpdates
IIterable<StorePackageUpdate> IEnumerable<StorePackageUpdate> IEnumerable<StorePackageUpdate> IEnumerable<StorePackageUpdate>

The set of StorePackageUpdate objects that represent the updated packages to download.

Returns
Exceptions
COMException COMException COMException COMException

If the ErrorCode property of the exception has the value 0x80070578 (ERROR_INVALID_WINDOW_HANDLE), this indicates that the method was not called on the UI thread. If you are calling this method in a desktop application that uses the Desktop Bridge, this can also indicate that you did not configure the StoreContext object to specify which application window is the owner window for modal dialogs shown by this method. For more information, see this article.

Remarks

To get the list of packages that have updates available, use the GetAppAndOptionalStorePackageUpdatesAsync method. After you download the packages, you can install packages by using the RequestDownloadAndInstallStorePackageUpdatesAsync method. For more information about using this method, including a code example, see Download and install package updates for your app.

This operation will not block. The IAsyncOperationWithProgress object returned by this method will complete after the update packages are downloaded.

When you call this method, the OS displays a dialog that tells the user that an app update is available to download and asks the user's permission to proceed with the download. If the user does not grant permission to start the download, the OverallState property of the StorePackageUpdateResult return value has the value Canceled.

The method that you assign to handle Progress notifications is called one time for each step in the download process for each package in this request. The Progress handler receives a StorePackageUpdateStatus argument that provides info about the update package that raised the progress notification.

See Also

RequestPurchaseAsync(String) RequestPurchaseAsync(String) RequestPurchaseAsync(String) RequestPurchaseAsync(String)

Requests the purchase for the specified app or add-on and displays the UI that is used to complete the transaction via the Microsoft Store.

Important

This method must be called on the UI thread.

public : IAsyncOperation<StorePurchaseResult> RequestPurchaseAsync(Platform::String storeId)
public IAsyncOperation<StorePurchaseResult> RequestPurchaseAsync(String storeId)
Public Function RequestPurchaseAsync(storeId As String) As IAsyncOperation( Of StorePurchaseResult )
var iAsyncOperation = storeContext.requestPurchaseAsync(storeId);
Parameters
storeId
Platform::String String String String

The Store ID of the app or the add-on that you want to purchase for the current user.

Returns

An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase.

Exceptions
COMException COMException COMException COMException

If the ErrorCode property of the exception has the value 0x80070578 (ERROR_INVALID_WINDOW_HANDLE), this indicates that the method was not called on the UI thread. If you are calling this method in a desktop application that uses the Desktop Bridge, this can also indicate that you did not configure the StoreContext object to specify which application window is the owner window for modal dialogs shown by this method. For more information, see this article.

Remarks

For more information about using this method, including a code example, see Enable in-app purchases of apps and add-ons.

The Store ID for an app or add-on is available in the Windows Dev Center dashboard, and it is returned by the StoreId property of the StoreProduct that represents the app or add-on.

See Also

RequestPurchaseAsync(String, StorePurchaseProperties) RequestPurchaseAsync(String, StorePurchaseProperties) RequestPurchaseAsync(String, StorePurchaseProperties) RequestPurchaseAsync(String, StorePurchaseProperties)

Requests the purchase for the specified app or add-on and displays the UI that is used to complete the transaction via the Microsoft Store. This method provides the option to specify additional details for a specific offer within a large catalog of products that are represented by a single listing in the Microsoft Store, including the product name to display to the user during the purchase.

Important

This method must be called on the UI thread.

public : IAsyncOperation<StorePurchaseResult> RequestPurchaseAsync(Platform::String storeId, StorePurchaseProperties storePurchaseProperties)
public IAsyncOperation<StorePurchaseResult> RequestPurchaseAsync(String storeId, StorePurchaseProperties storePurchaseProperties)
Public Function RequestPurchaseAsync(storeId As String, storePurchaseProperties As StorePurchaseProperties) As IAsyncOperation( Of StorePurchaseResult )
var iAsyncOperation = storeContext.requestPurchaseAsync(storeId, storePurchaseProperties);
Parameters
storeId
Platform::String String String String

The Store ID of the app or the add-on that you want to purchase for the current user.

storePurchaseProperties
StorePurchaseProperties StorePurchaseProperties StorePurchaseProperties StorePurchaseProperties

An object that specifies additional info for the purchase request, including the product name to display to the user during the purchase.

Returns

An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase.

Exceptions
COMException COMException COMException COMException

If the ErrorCode property of the exception has the value 0x80070578 (ERROR_INVALID_WINDOW_HANDLE), this indicates that the method was not called on the UI thread. If you are calling this method in a desktop application that uses the Desktop Bridge, this can also indicate that you did not configure the StoreContext object to specify which application window is the owner window for modal dialogs shown by this method. For more information, see this article.

Remarks

The Store ID for an app or add-on is available in the Windows Dev Center dashboard, and it is returned by the StoreId property of the StoreProduct that represents the app or add-on.

See Also

Events

OfflineLicensesChanged OfflineLicensesChanged OfflineLicensesChanged OfflineLicensesChanged

Raised 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 OfflineLicensesChanged<StoreContext,  object>
public event TypedEventHandler OfflineLicensesChanged<StoreContext,  object>
Public Event TypedEventHandler OfflineLicensesChanged( Of ( Of StoreContext ), ( Of  object ))
function onOfflineLicensesChanged(eventArgs){/* Your code */}


storeContext.addEventListener("offlineLicensesChanged", onOfflineLicensesChanged);
storeContext.removeEventListener("offlineLicensesChanged", onOfflineLicensesChanged);

Remarks

When this event is raised, you can get the latest app license from the Microsoft Store by calling the GetAppLicenseAsync method. The StoreAppLicense object returned by this method also contains the latest add-on licenses for the app in the AddOnLicenses property.

For more information about the OfflineLicensesChanged event, including a code example, see Implement a trial version of your app.

Note

This event is the equivalent of the LicenseChanged event in the Windows.ApplicationModel.Store namespace.

See Also

See Also