Store​Context Store​Context Store​Context Store​Context Class

Definition

Provides members you can use to access and manage Windows Store-related data for the current app. For example, you can use members of this class to get Windows 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, IStoreContext2public sealed class StoreContext : IStoreContext, IStoreContext2Public NotInheritable Class StoreContext Implements IStoreContext, IStoreContext2// You can use this class in JavaScript.
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, and this namespace can only be used in apps that target this release or a later release. If your app 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 Windows 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 Windows 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 Windows 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 Windows 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// You can use this property in JavaScript.
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 )// You can use this method in JavaScript.
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<String>, Package) FindStoreProductForPackageAsync(IIterable<String>, Package) FindStoreProductForPackageAsync(IIterable<String>, Package) FindStoreProductForPackageAsync(IIterable<String>, 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 )// You can use this method in JavaScript.
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 Windows 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( Of IReadOnlyListStorePackageUpdate )// You can use this method in JavaScript.
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 )// You can use this method in JavaScript.
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<String>) GetAssociatedStoreProductsAsync(IIterable<String>) GetAssociatedStoreProductsAsync(IIterable<String>) GetAssociatedStoreProductsAsync(IIterable<String>)

Gets the list of 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 )// You can use this method in JavaScript.
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<String>, UInt32) GetAssociatedStoreProductsWithPagingAsync(IIterable<String>, UInt32) GetAssociatedStoreProductsWithPagingAsync(IIterable<String>, UInt32) GetAssociatedStoreProductsWithPagingAsync(IIterable<String>, UInt32)

Gets the list of 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 )// You can use this method in JavaScript.
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 )// You can use this method in JavaScript.
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 Windows 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 )// You can use this method in JavaScript.
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 Windows 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 Windows 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 Windows 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 Windows 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 )// You can use this method in JavaScript.
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 Windows 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 Windows 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 Windows 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 Windows 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// You can use this method in JavaScript.
Returns

An object that you can use to access and manage Windows 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 Windows 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 Windows 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// You can use this method in JavaScript.
Parameters
user
User User User User

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

Returns

An object that you can use to access and manage Windows 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 Windows 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 Windows 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 )// You can use this method in JavaScript.
Returns

An asynchronous operation that, on successful completion, returns a StoreProductResult object that contains Windows 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<String>, IIterable<String>) GetStoreProductsAsync(IIterable<String>, IIterable<String>) GetStoreProductsAsync(IIterable<String>, IIterable<String>) GetStoreProductsAsync(IIterable<String>, IIterable<String>)

Gets Windows Store listing info for the specified products that can be purchased from within 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 )// You can use this method in JavaScript.
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 Windows Store listing info for the specified products 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.

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.

See Also

GetUserCollectionAsync(IIterable<String>) GetUserCollectionAsync(IIterable<String>) GetUserCollectionAsync(IIterable<String>) GetUserCollectionAsync(IIterable<String>)

Gets Windows 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 )// You can use this method in JavaScript.
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 Windows 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<String>, UInt32) GetUserCollectionWithPagingAsync(IIterable<String>, UInt32) GetUserCollectionWithPagingAsync(IIterable<String>, UInt32) GetUserCollectionWithPagingAsync(IIterable<String>, UInt32)

Gets Windows 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 )// You can use this method in JavaScript.
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 Windows 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 Windows 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 )// You can use this method in JavaScript.
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 Windows 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 Windows Store. For example, consider a scenario where you call ReportConsumableFulfillmentAsync with a given pair of productStoreId and trackingId values, the Windows 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 Windows 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<String>) RequestDownloadAndInstallStorePackagesAsync(IIterable<String>) RequestDownloadAndInstallStorePackagesAsync(IIterable<String>) RequestDownloadAndInstallStorePackagesAsync(IIterable<String>)

Downloads and installs the specified downloadable content (DLC) packages for the current app from the Windows 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, StorePackageUpdateStatus )// You can use this method in JavaScript.
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<StorePackageUpdate>) RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadAndInstallStorePackageUpdatesAsync(IIterable<StorePackageUpdate>)

Downloads and installs the specified package updates for the current app from the Windows 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, StorePackageUpdateStatus )// You can use this method in JavaScript.
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<StorePackageUpdate>) RequestDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>) RequestDownloadStorePackageUpdatesAsync(IIterable<StorePackageUpdate>)

Downloads the specified package updates for the current app from the Windows 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, StorePackageUpdateStatus )// You can use this method in JavaScript.
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 Windows 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 )// You can use this method in JavaScript.
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 Windows 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 Windows 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 )// You can use this method in JavaScript.
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 OfflineLicensesChanged<StoreContext,  object>// You can use this event in JavaScript.

Remarks

When this event is raised, you can get the latest app license from the Windows 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