Current​App Current​App Current​App Current​App Class

Definition

Defines methods and properties you can use to get license and listing info about the current app and perform in-app product purchases.

public : static class CurrentApppublic static class CurrentAppPublic Static Class CurrentApp// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

This object obtains its data from the Windows Store, so you must have a developer account and the app must be published in the Windows Store. Before submitting to the Windows Store, you can test your code with a simulated version of this class (whose state is initialized from an XML file). See CurrentAppSimulator.

Note

If your app targets Windows 10, version 1607 or later, we recommend that you use members of the Windows.Services.Store namespace instead of the Windows.ApplicationModel.Store namespace. The Windows.Services.Store namespace supports the latest add-on types, such as Store-managed consumable add-ons, and is designed to be compatible with future types of products and features supported by Windows Dev Center and the Store. The Windows.Services.Store namespace is also designed to have better performance. For more information, see In-app purchases and trials.

The CurrentApp class is not supported in Windows desktop applications that use the Desktop Bridge. These applications must use the Windows.Services.Store namespace to implement in-app purchases and trials. For more information, see In-app purchases and trials.

Properties

AppId AppId AppId AppId

Gets the GUID generated by the Windows Store when your app has been certified for listing in the Windows Store.

Note

Once your app is in the Windows Store, future app updates or changes to the app description will not result in a change to the CurrentApp.AppId.

public : static PlatForm::Guid AppId { get; }public static Guid AppId { get; }Public Static ReadOnly Property AppId As Guid// You can use this property in JavaScript.
Value
PlatForm::Guid Guid Guid Guid

The GUID that identifies the app in the Windows Store.

Remarks

To get a link to your app within the Windows Store, which references the same GUID, use LinkUri.

LicenseInformation LicenseInformation LicenseInformation LicenseInformation

Gets the license metadata for the current app.

public : static LicenseInformation LicenseInformation { get; }public static LicenseInformation LicenseInformation { get; }Public Static ReadOnly Property LicenseInformation As LicenseInformation// You can use this property in JavaScript.
Value
LicenseInformation LicenseInformation LicenseInformation LicenseInformation

The license metadata for the current app.

Remarks

This API does not require a network connection.

LinkUri LinkUri LinkUri LinkUri

Gets the Uniform Resource Identifier (URI) of the app's listing page in the web catalog of the Windows Store.

public : static Uri LinkUri { get; }public static Uri LinkUri { get; }Public Static ReadOnly Property LinkUri As Uri// You can use this property in JavaScript.
Value
Uri Uri Uri Uri

The Uniform Resource Identifier (URI) of the app's listing page in the Windows Store.

Methods

GetAppPurchaseCampaignIdAsync() GetAppPurchaseCampaignIdAsync() GetAppPurchaseCampaignIdAsync() GetAppPurchaseCampaignIdAsync()

Retrieves the promotion campaign ID for the current app.

public : static IAsyncOperation<PlatForm::String> GetAppPurchaseCampaignIdAsync()public static IAsyncOperation<string> GetAppPurchaseCampaignIdAsync()Public Static Function GetAppPurchaseCampaignIdAsync() As IAsyncOperation( Of string )// You can use this method in JavaScript.
Returns

The advertising campaign ID for your app.

Remarks

Starting in Windows 10, you can seed the installation URL for your app with an ID that represents a custom promotion campaign. This enables you to publicize the installation URL in different locations and use the campaign ID to determine which location the customer clicked on the installation URL. Use the GetAppPurchaseCampaignIdAsync method to retrieve the campaign ID for the current app. For more information about custom app promotion campaigns, see Create a custom app promotion campaign.

See Also

GetAppReceiptAsync() GetAppReceiptAsync() GetAppReceiptAsync() GetAppReceiptAsync()

Requests all receipts for the purchase of the app and any in-app products. For examples of how receipt information can be used, see Using receipts to verify product purchases.

public : static IAsyncOperation<PlatForm::String> GetAppReceiptAsync()public static IAsyncOperation<string> GetAppReceiptAsync()Public Static Function GetAppReceiptAsync() As IAsyncOperation( Of string )// You can use this method in JavaScript.
Returns

An XML-formatted string that contains all receipt information for the purchase of the app and any in-app products.

Remarks

For more information about the contents of the receipt, see Using receipts to verify product purchases.

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 : static IAsyncOperation<PlatForm::String> GetCustomerCollectionsIdAsync(PlatForm::String serviceTicket, PlatForm::String publisherUserId)public static IAsyncOperation<string> GetCustomerCollectionsIdAsync(String serviceTicket, String publisherUserId)Public Static 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

The collections ID key for the current user. This key is valid for 90 days.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

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 in-app product (IAP) 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 : static IAsyncOperation<PlatForm::String> GetCustomerPurchaseIdAsync(PlatForm::String serviceTicket, PlatForm::String publisherUserId)public static IAsyncOperation<string> GetCustomerPurchaseIdAsync(String serviceTicket, String publisherUserId)Public Static 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

The purchase ID key for the current user. This key is valid for 90 days.

Additional features and requirements
Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

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 in-app product (IAP) that is published through the Windows Store. For more information, see Manage product entitlements from a service.

See Also

GetProductReceiptAsync(String) GetProductReceiptAsync(String) GetProductReceiptAsync(String) GetProductReceiptAsync(String)

Requests the receipt for the specified product ID. For examples of how receipt information can be used, see Using receipts to verify product purchases.

public : static IAsyncOperation<PlatForm::String> GetProductReceiptAsync(PlatForm::String productId)public static IAsyncOperation<string> GetProductReceiptAsync(String productId)Public Static Function GetProductReceiptAsync(productId As String) As IAsyncOperation( Of string )// You can use this method in JavaScript.
Parameters
productId
PlatForm::String String String String

The unique identifier for the product that you specified this identifier when you submitted the app to the Windows Store

Returns

An XML-formatted string that contains the receipt for the specified productId.

Remarks

For more information about the contents of the receipt, see Using receipts to verify product purchases.

GetUnfulfilledConsumablesAsync() GetUnfulfilledConsumablesAsync() GetUnfulfilledConsumablesAsync() GetUnfulfilledConsumablesAsync()

Returns a list of purchased consumable in-app products that have not been reported to the Windows Store as fulfilled.

public : static IAsyncOperation<IVectorView<UnfulfilledConsumable>> GetUnfulfilledConsumablesAsync()public static IAsyncOperation<IReadOnlyList<UnfulfilledConsumable>> GetUnfulfilledConsumablesAsync()Public Static Function GetUnfulfilledConsumablesAsync() As IAsyncOperation( Of IReadOnlyListUnfulfilledConsumable )// You can use this method in JavaScript.
Returns
IAsyncOperation<IVectorView<UnfulfilledConsumable>> IAsyncOperation<IReadOnlyList<UnfulfilledConsumable>> IAsyncOperation<IReadOnlyList<UnfulfilledConsumable>> IAsyncOperation<IReadOnlyList<UnfulfilledConsumable>>

When the operation completes, a list of consumable in-app products not yet reported as fulfilled is returned (UnfulfilledConsumable objects). Each item of this list provides the product ID, offer ID, and transaction ID associated with a product.

LoadListingInformationAsync() LoadListingInformationAsync() LoadListingInformationAsync() LoadListingInformationAsync()

Loads the app's listing information asynchronously.

The returned ListingInformation object contains listing information (e.g. name, price, age rating) specific to the market the user currently resides in. Additionally, the listing information for available in-app products is also provided.

public : static IAsyncOperation<ListingInformation> LoadListingInformationAsync()public static IAsyncOperation<ListingInformation> LoadListingInformationAsync()Public Static Function LoadListingInformationAsync() As IAsyncOperation( Of ListingInformation )// You can use this method in JavaScript.
Returns

Remarks

Calling this method requires an internet connection.

LoadListingInformationByKeywordsAsync(IIterable<String>) LoadListingInformationByKeywordsAsync(IIterable<String>) LoadListingInformationByKeywordsAsync(IIterable<String>) LoadListingInformationByKeywordsAsync(IIterable<String>)

Loads the app listing information asynchronously, returning features and products in the ProductListings collection that match all supplied keywords.

public : static IAsyncOperation<ListingInformation> LoadListingInformationByKeywordsAsync(IIterable<PlatForm::String> keywords)public static IAsyncOperation<ListingInformation> LoadListingInformationByKeywordsAsync(IEnumerable<String> keywords)Public Static Function LoadListingInformationByKeywordsAsync(keywords As IEnumerable<String>) As IAsyncOperation( Of ListingInformation )// You can use this method in JavaScript.
Parameters
keywords
IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

The list of keywords by which to filter the ProductListings collection that is returned in the ListingInformation object.

Returns

The app's listing information, with ProductListings collection filtered by keywords. If the method fails, it returns an HRESULT error code. If no products or features are found that match all of the given keywords, the ProductListings collection will be empty.

LoadListingInformationByProductIdsAsync(IIterable<String>) LoadListingInformationByProductIdsAsync(IIterable<String>) LoadListingInformationByProductIdsAsync(IIterable<String>) LoadListingInformationByProductIdsAsync(IIterable<String>)

Loads the app listing information asynchronously, returning features and products in the ProductListings collection that match any of the given products IDs.

public : static IAsyncOperation<ListingInformation> LoadListingInformationByProductIdsAsync(IIterable<PlatForm::String> productIds)public static IAsyncOperation<ListingInformation> LoadListingInformationByProductIdsAsync(IEnumerable<String> productIds)Public Static Function LoadListingInformationByProductIdsAsync(productIds As IEnumerable<String>) As IAsyncOperation( Of ListingInformation )// You can use this method in JavaScript.
Parameters
productIds
IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

The list of product IDs by which to filter the ProductListings collection.

Returns

The app's listing information, with ProductListings collection filtered by product IDs. If the method fails, it returns an HRESULT error code. If no products or features are found that match the given product IDs, the ProductListings collection will be empty.

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

Notifies the Windows Store that the purchase of a consumable add-on (also called an in-app product or IAP) is fulfilled and that the user has the right to access the content.

public : static IAsyncOperation<FulfillmentResult> ReportConsumableFulfillmentAsync(PlatForm::String productId, PlatForm::Guid transactionId)public static IAsyncOperation<FulfillmentResult> ReportConsumableFulfillmentAsync(String productId, Guid transactionId)Public Static Function ReportConsumableFulfillmentAsync(productId As String, transactionId As Guid) As IAsyncOperation( Of FulfillmentResult )// You can use this method in JavaScript.
Parameters
productId
PlatForm::String String String String

The product ID of the consumable add-on to report as fulfilled.

transactionId
PlatForm::Guid Guid Guid Guid

The transaction ID for the purchase of the consumable add-on.

Returns

Remarks

The product ID is the string that the app uses to identify the add-on. You enter the product ID when submitting your add-on in the Windows Dev Center dashboard, where it is associated with the description, price tier and lifetime. For more information, see How to use product IDs for add-ons in your code.

A unique transaction ID is required for each instance of a consumable product that has been purchased more than once.

ReportProductFulfillment(String) ReportProductFulfillment(String) ReportProductFulfillment(String) ReportProductFulfillment(String)

Notifies the Windows Store that the application has fulfilled the in-app product. This product cannot be re-purchased until the app has confirmed fulfillment using this method.

public : static void ReportProductFulfillment(PlatForm::String productId)public static void ReportProductFulfillment(String productId)Public Static Function ReportProductFulfillment(productId As String) As void// You can use this method in JavaScript.
Parameters
productId
PlatForm::String String String String

The ID of the product that has been delivered to the user.

RequestAppPurchaseAsync(Boolean) RequestAppPurchaseAsync(Boolean) RequestAppPurchaseAsync(Boolean) RequestAppPurchaseAsync(Boolean)

Requests the purchase of a full app license.

public : static IAsyncOperation<PlatForm::String> RequestAppPurchaseAsync(bool includeReceipt)public static IAsyncOperation<string> RequestAppPurchaseAsync(Boolean includeReceipt)Public Static Function RequestAppPurchaseAsync(includeReceipt As Boolean) As IAsyncOperation( Of string )// You can use this method in JavaScript.
Parameters
includeReceipt
bool Boolean Boolean Boolean

Determines if this method should return the receipts for this app.

Returns

If the includeReceipt parameter is set to true, this string contains XML that represents all receipts for the app and any in-app purchases. If includeReceipt is set to false, this string is empty.

Remarks

This method returns a success value even if:

  • No network connection is available.
  • The user cancels out of the dialog.
  • The user's authentication fails.

You should treat a success result as indicating the async process completed without errors. To ensure that the transaction itself was successful, check the LicenseInformation element in the returned receipt.

For information about the contents of the receipt returned by this method, see Using receipts to verify product purchases.

RequestProductPurchaseAsync(String) RequestProductPurchaseAsync(String) RequestProductPurchaseAsync(String) RequestProductPurchaseAsync(String)

Requests the purchase of an add-on (also called an in-app product or IAP). Additionally, calling this method displays the UI that is used to complete the transaction via the Windows Store.

public : static IAsyncOperation<PurchaseResults> RequestProductPurchaseAsync(PlatForm::String productId)public static IAsyncOperation<PurchaseResults> RequestProductPurchaseAsync(String productId)Public Static Function RequestProductPurchaseAsync(productId As String) As IAsyncOperation( Of PurchaseResults )// You can use this method in JavaScript.
Parameters
productId
PlatForm::String String String String

The product ID of the add-on to purchase.

Returns

Remarks

The product ID is the string that the app uses to identify the add-on. You enter the product ID when submitting your add-on in the Windows Dev Center dashboard, where it is associated with the description, price tier and lifetime. For more information, see How to use product IDs for add-ons in your code.

You can see an example of how to use this method in our code sample.

See Also

RequestProductPurchaseAsync(String, Boolean) RequestProductPurchaseAsync(String, Boolean) RequestProductPurchaseAsync(String, Boolean) RequestProductPurchaseAsync(String, Boolean)

Note

RequestProductPurchaseAsync(String, Boolean) may be altered or unavailable for releases after Windows 8.1. Instead, use RequestProductPurchaseAsync(String).

Requests the purchase of an add-on (also called an in-app product or IAP). Additionally, calling this method displays the UI that is used to complete the transaction via the Windows Store.

public : static IAsyncOperation<PlatForm::String> RequestProductPurchaseAsync(PlatForm::String productId, bool includeReceipt)public static IAsyncOperation<string> RequestProductPurchaseAsync(String productId, Boolean includeReceipt)Public Static Function RequestProductPurchaseAsync(productId As String, includeReceipt As Boolean) As IAsyncOperation( Of string )// You can use this method in JavaScript.
Parameters
productId
PlatForm::String String String String

The product ID of the add-on to purchase.

includeReceipt
bool Boolean Boolean Boolean

Determines if the method should return the receipts for the specified productId.

Returns

A string providing in-app transaction details for the provided productId. If includeReceipt is set true, the returned string will include a full receipt xml.

Remarks

The remarks for RequestProductPurchaseAsync(String) also apply to this overload.

To confirm whether the product license is active after a successful call to this overload, use the LicenseInformation.IsActive property.

See Also

RequestProductPurchaseAsync(String, String, ProductPurchaseDisplayProperties) RequestProductPurchaseAsync(String, String, ProductPurchaseDisplayProperties) RequestProductPurchaseAsync(String, String, ProductPurchaseDisplayProperties) RequestProductPurchaseAsync(String, String, ProductPurchaseDisplayProperties)

Requests the purchase of an add-on (also called an in-app product or IAP). Additionally, calling this method displays the UI that is used to complete the transaction via the Windows Store. This overload includes parameters you can use to display details for a specific offer within a large catalog of in-app purchases that is represented by a single product entry in the Store.

public : static IAsyncOperation<PurchaseResults> RequestProductPurchaseAsync(PlatForm::String productId, PlatForm::String offerId, ProductPurchaseDisplayProperties displayProperties)public static IAsyncOperation<PurchaseResults> RequestProductPurchaseAsync(String productId, String offerId, ProductPurchaseDisplayProperties displayProperties)Public Static Function RequestProductPurchaseAsync(productId As String, offerId As String, displayProperties As ProductPurchaseDisplayProperties) As IAsyncOperation( Of PurchaseResults )// You can use this method in JavaScript.
Parameters
productId
PlatForm::String String String String

The product ID of the add-on to purchase.

offerId
PlatForm::String String String String

The specific in-app feature or content within the large purchase catalog represented on the Windows Store by the productId. This value correlates with the content your app is responsible for fulfilling. The Windows Store only uses this value to itemize the PurchaseResults.

displayProperties
ProductPurchaseDisplayProperties ProductPurchaseDisplayProperties ProductPurchaseDisplayProperties ProductPurchaseDisplayProperties

The name of the app feature or content offer that is displayed to the user at time of purchase.

Returns

Remarks

The remarks for RequestProductPurchaseAsync(String) also apply to this overload.

See Also

See Also