CurrentApp CurrentApp CurrentApp 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
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

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 Guid AppId { get; }public static Guid AppId { get; }Public Static ReadOnly Property AppId As Guid
Value
System.Guid System.Guid System.Guid

The GUID that identifies the app in the Windows Store.

Attributes

Remarks

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

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
Value
LicenseInformation LicenseInformation LicenseInformation

The license metadata for the current app.

Attributes

Remarks

This API does not require a network connection.

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
Value
Uri Uri Uri

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

Attributes

Methods

GetAppPurchaseCampaignIdAsync() GetAppPurchaseCampaignIdAsync() GetAppPurchaseCampaignIdAsync()

Retrieves the promotion campaign ID for the current app.

public static IAsyncOperation<string> GetAppPurchaseCampaignIdAsync()public static IAsyncOperation<string> GetAppPurchaseCampaignIdAsync()Public Static Function GetAppPurchaseCampaignIdAsync() As IAsyncOperation( Of string )
Returns

The advertising campaign ID for your app.

Attributes

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()

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<string> GetAppReceiptAsync()public static IAsyncOperation<string> GetAppReceiptAsync()Public Static Function GetAppReceiptAsync() As IAsyncOperation( Of string )
Returns

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

Attributes

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)

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<string> GetCustomerCollectionsIdAsync(String serviceTicket, 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 )
Parameters
serviceTicket
System.String System.String System.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
System.String System.String System.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.

Attributes

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)

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<string> GetCustomerPurchaseIdAsync(String serviceTicket, 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 )
Parameters
serviceTicket
System.String System.String System.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
System.String System.String System.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.

Attributes

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)

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<string> GetProductReceiptAsync(String productId)public static IAsyncOperation<string> GetProductReceiptAsync(String productId)Public Static Function GetProductReceiptAsync(productId As String) As IAsyncOperation( Of string )
Parameters
productId
System.String System.String System.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.

Attributes

Remarks

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

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<IVectorView<UnfulfilledConsumable>> GetUnfulfilledConsumablesAsync()Public Static Function GetUnfulfilledConsumablesAsync() As IAsyncOperation( Of IVectorViewUnfulfilledConsumable )
Returns

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.

Attributes

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 )
Returns

The apps' listing information. If the method fails, it returns an HRESULT error code.

Attributes

Remarks

Calling this method requires an internet connection.

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<String> keywords)public static IAsyncOperation<ListingInformation> LoadListingInformationByKeywordsAsync(IIterable<String> keywords)Public Static Function LoadListingInformationByKeywordsAsync(keywords As IIterable<String>) As IAsyncOperation( Of ListingInformation )
Parameters
keywords

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.

Attributes

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<String> productIds)public static IAsyncOperation<ListingInformation> LoadListingInformationByProductIdsAsync(IIterable<String> productIds)Public Static Function LoadListingInformationByProductIdsAsync(productIds As IIterable<String>) As IAsyncOperation( Of ListingInformation )
Parameters
productIds

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.

Attributes

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

Notifies the Windows Store that the purchase of a consumable is fulfilled and that the user has the right to access the content.

public static IAsyncOperation<FulfillmentResult> ReportConsumableFulfillmentAsync(String productId, 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 )
Parameters
productId
System.String System.String System.String

Identifies the consumable.

transactionId
System.Guid System.Guid System.Guid

Identifies a transaction that includes the purchase of the consumable (productId).

Returns

A value that indicates the status of fulfillment for a consumable in-app product. Possible values are defined by the FulfillmentResult enumeration.

Attributes

Remarks

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

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(String productId)public static void ReportProductFulfillment(String productId)Public Static Function ReportProductFulfillment(productId As String) As void
Parameters
productId
System.String System.String System.String

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

Attributes

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

Requests the purchase of a full app license.

public static IAsyncOperation<string> RequestAppPurchaseAsync(Boolean includeReceipt)public static IAsyncOperation<string> RequestAppPurchaseAsync(Boolean includeReceipt)Public Static Function RequestAppPurchaseAsync(includeReceipt As Boolean) As IAsyncOperation( Of string )
Parameters
includeReceipt
System.Boolean System.Boolean System.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.

Attributes

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)

Requests the purchase of an in-app product. Additionally, calling this method displays the UI that is used to complete the transaction via the Windows Store.

public static IAsyncOperation<PurchaseResults> RequestProductPurchaseAsync(String productId)public static IAsyncOperation<PurchaseResults> RequestProductPurchaseAsync(String productId)Public Static Function RequestProductPurchaseAsync(productId As String) As IAsyncOperation( Of PurchaseResults )
Parameters
productId
System.String System.String System.String

Specifies the id of the in-app product.

Returns

The results of the in-app product purchase request.

Attributes

Remarks

Use the LicenseInformation.IsActive property to confirm that a product license is active after a successful RequestProductPurchaseAsync call.

Note

This method of confirming a successful purchase is only applicable to the RequestProductPurchaseAsync overloads that don't return a PurchaseResults object.

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

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 in-app product. Additionally, calling this method displays the UI that is used to complete the transaction via the Windows Store.

public static IAsyncOperation<string> RequestProductPurchaseAsync(String productId, Boolean includeReceipt)public static IAsyncOperation<string> RequestProductPurchaseAsync(String productId, Boolean includeReceipt)Public Static Function RequestProductPurchaseAsync(productId As String, includeReceipt As Boolean) As IAsyncOperation( Of string )
Parameters
productId
System.String System.String System.String

Specifies the id of the in-app product.

includeReceipt
System.Boolean System.Boolean System.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.

Attributes

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

Requests the purchase of an in-app product. Additionally, calling this method displays the UI that is used to complete the transaction via the Windows Store.The resulting RequestProductPurchaseAsync object includes the parameters required 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(String productId, 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 )
Parameters
productId
System.String System.String System.String

Specifies the id of the in-app product.

offerId
System.String System.String System.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

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

Returns

The results of the in-app product purchase request.

Attributes

Remarks

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

See Also