Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion windows.services.store/storecollectiondata.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,47 @@ public class StoreCollectionData : Windows.Services.Store.IStoreCollectionData
Provides additional data for a product SKU that the user has an entitlement to use.

## -remarks
The [StoreSku.CollectionData](storesku_collectiondata.md) property returns an object of this type.
The [StoreSku.CollectionData](storesku_collectiondata.md) property returns an object of this type. This object is only available for SKUs that the user has an entitlement to use (for example, SKUs that the user has purchased, downloaded for free, or acquired through other means from the Microsoft Store).

The **StoreCollectionData** object provides properties such as [AcquiredDate](storecollectiondata_acquireddate.md), which indicates when the user first acquired the SKU from the Microsoft Store.

## -examples
The following example shows how to access **StoreCollectionData** for products in the user's collection.

```csharp
private async void GetCollectionData()
{
// Get the StoreContext for the current user
StoreContext storeContext = StoreContext.GetDefault();

// Get the user's collection of owned products
string[] productKinds = { "Application", "Durable" };
StoreProductQueryResult queryResult = await storeContext.GetUserCollectionAsync(productKinds);

if (queryResult.ExtendedError == null)
{
foreach (StoreProduct product in queryResult.Products)
{
foreach (StoreSku sku in product.Skus)
{
// Check if the user has an entitlement for this SKU
if (sku.CollectionData != null)
{
StoreCollectionData collectionData = sku.CollectionData;

// Access properties of the collection data
DateTime acquiredDate = collectionData.AcquiredDate;
bool isTrial = collectionData.IsTrial;

System.Diagnostics.Debug.WriteLine($"Product: {product.Title}");
System.Diagnostics.Debug.WriteLine($"Acquired: {acquiredDate}");
System.Diagnostics.Debug.WriteLine($"Is Trial: {isTrial}");
}
}
}
}
}
```

## -see-also
[StoreSku.CollectionData](storesku_collectiondata.md), [StoreCollectionData.AcquiredDate](storecollectiondata_acquireddate.md), [StoreContext.GetUserCollectionAsync](storecontext_getusercollectionasync_822351662.md)
45 changes: 43 additions & 2 deletions windows.services.store/storecollectiondata_acquireddate.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,54 @@ public Windows.Foundation.DateTime AcquiredDate { get; }
# Windows.Services.Store.StoreCollectionData.AcquiredDate

## -description
Gets the date on which the product SKU was acquired.
Gets the date on which the product SKU was acquired by the user from the Microsoft Store.

## -property-value
The date on which the product SKU was acquired.
The date on which the product SKU was acquired by the user from the Microsoft Store.

## -remarks
This property represents the date when the user first acquired the product SKU from the Microsoft Store, such as through a purchase, redemption, or free download. This is different from the installation date, which represents when the app package was installed on the device. The acquired date remains the same even if the app is uninstalled and reinstalled, while the installation date would change.

The **AcquiredDate** is only available for products that the user has an entitlement to use. To access this property, you must first retrieve the user's collection of owned products using [StoreContext.GetUserCollectionAsync](storecontext_getusercollectionasync_822351662.md) or [StoreContext.GetUserCollectionWithPagingAsync](storecontext_getusercollectionwithpagingasync_1326616908.md).

## -examples
The following example shows how to get the acquired date for products in the user's collection.

```csharp
private async void GetUserCollectionAcquiredDates()
{
// Get the StoreContext for the current user
StoreContext storeContext = StoreContext.GetDefault();

// Get the user's collection of owned products
string[] productKinds = { "Application", "Durable" };
StoreProductQueryResult queryResult = await storeContext.GetUserCollectionAsync(productKinds);

if (queryResult.ExtendedError == null)
{
foreach (StoreProduct product in queryResult.Products)
{
// Check each SKU for collection data
foreach (StoreSku sku in product.Skus)
{
if (sku.CollectionData != null)
{
// The user has an entitlement for this SKU
DateTime acquiredDate = sku.CollectionData.AcquiredDate;
System.Diagnostics.Debug.WriteLine($"Product: {product.Title}");
System.Diagnostics.Debug.WriteLine($"SKU: {sku.Title}");
System.Diagnostics.Debug.WriteLine($"Acquired on: {acquiredDate}");
}
}
}
}
else
{
// Handle error
System.Diagnostics.Debug.WriteLine($"Error getting user collection: {queryResult.ExtendedError}");
}
}
```

## -see-also
[StoreCollectionData](storecollectiondata.md), [StoreSku.CollectionData](storesku_collectiondata.md), [StoreContext.GetUserCollectionAsync](storecontext_getusercollectionasync_822351662.md), [StoreContext.GetUserCollectionWithPagingAsync](storecontext_getusercollectionwithpagingasync_1326616908.md)
7 changes: 6 additions & 1 deletion windows.services.store/storesku_collectiondata.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ public Windows.Services.Store.StoreCollectionData CollectionData { get; }
Gets additional data for the current product SKU, if the user has an entitlement to use the SKU.

## -property-value
An object that provides additional data for the current product SKU, if the user has an entitlement to use the SKU.
An object that provides additional data for the current product SKU, if the user has an entitlement to use the SKU. This property returns **null** if the user does not have an entitlement for the SKU.

## -remarks
This property returns a [StoreCollectionData](storecollectiondata.md) object only for SKUs that the user has acquired or is entitled to use. This includes SKUs that the user has purchased, downloaded for free, or acquired through other means from the Microsoft Store.

To access **StoreSku** objects with collection data, use methods such as [GetUserCollectionAsync](storecontext_getusercollectionasync_822351662.md) to retrieve the user's collection of owned products.

## -examples
For a complete example of how to access and use this property, see [StoreCollectionData](storecollectiondata.md).

## -see-also
[StoreCollectionData](storecollectiondata.md), [StoreCollectionData.AcquiredDate](storecollectiondata_acquireddate.md), [StoreContext.GetUserCollectionAsync](storecontext_getusercollectionasync_822351662.md)