Listing available products

We need to present the details about what products or subscriptions are available for purchase so that the users can verify what they want before making any purchases.

How to do it...

We can request a list of Product instances using the QueryInventoryAsync() method:

  1. The QueryInventoryAsync() method returns the product details when invoked with the desired product IDs and the Product ItemType instance:
    var productIds = new string[] {
      "managed.one",
      "managed.two"
    };
    var products = await billing.QueryInventoryAsync(
      productIds, ItemType.Product);
    
  2. If we have any subscriptions, we can repeat the same process but we will use the Subscription ItemType type this time:
    var productIds = new string[] { "subscription.one" }; var subscriptions ...

Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.