/// <summary> /// Attachs to purchase manager. /// </summary> /// <param name="purchaseManager">Purchase manager.</param> public void AttachToPurchaseManager(UIStoryboard Storyboard, InAppPurchaseManager purchaseManager) { // Save connection to purchase manager _Storyboard = Storyboard; PurchaseManager = purchaseManager; // Scan sub view controllers foreach (UIViewController controller in ChildViewControllers) { //Console.WriteLine (controller.ToString ()); // Wireup sub views to the master purchase controller if (controller is PurchaseTableViewController) { // Found the previous purchase table, save and initialize _purchaseTable = (PurchaseTableViewController)controller; _purchaseTable.AttachToPurchaseManager(_Storyboard, purchaseManager); } else if (controller is StoreTableViewController) { // Found the available products for sale table, save and initialize _storeTable = (StoreTableViewController)controller; _storeTable.AttachToPurchaseManager(_Storyboard, purchaseManager); } //else if (controller is FeaturesController) //{ // //// Found special features, save and initialize // //_featuresController = (FeaturesController)controller; // //_featuresController.AttachToPurchaseManager(_Storyboard, purchaseManager); //} //else if (controller is SettingsController) //{ // // Found settings, save and initialize // _settingsController = (SettingsController)controller; // _settingsController.AttachToPurchaseManager(_Storyboard, purchaseManager); //} } }
public void DisplayProduct(PurchaseTableViewController controller, InAppPurchaseManager purchaseManager, InAppProduct product) { // Save copy of the current product and purchase manager _controller = controller; _purchaseManager = purchaseManager; Product = product; // Set image based on the product type switch (product.ProductType) { case InAppProductType.NonConsumable: if (product.Downloadable) { ItemImage.Image = UIImage.FromFile("Images/Downloadable.png"); } else { ItemImage.Image = UIImage.FromFile("Images/NonConsumable.png"); } break; case InAppProductType.Consumable: ItemImage.Image = UIImage.FromFile("Images/Consumable.png"); break; case InAppProductType.AutoRenewableSubscription: ItemImage.Image = UIImage.FromFile("Images/Subscription.png"); break; case InAppProductType.FreeSubscription: ItemImage.Image = UIImage.FromFile("Images/FreeSubscription.png"); break; case InAppProductType.NonRenewingSubscription: ItemImage.Image = UIImage.FromFile("Images/NonRenewingSubscription.png"); break; case InAppProductType.Unknown: ItemImage.Image = UIImage.FromFile("Images/Unknown.png"); break; } // Fill in the rest of the information ItemTitle.Text = product.Title; ItemDescription.Text = product.Description; UpdateButton.Hidden = true; // Take action based on the product type switch (Product.ProductType) { case InAppProductType.Consumable: // Show remaining quantity AvailableQuantity.Hidden = false; AvailableQuantity.Text = String.Format("{0} qty", product.AvailableQuantity); break; case InAppProductType.AutoRenewableSubscription: case InAppProductType.NonRenewingSubscription: // Force this product to use a calculated date product.UseCalculatedExpirationDate = true; // Show expiration date AvailableQuantity.Hidden = false; AvailableQuantity.Text = String.Format("Exp {0:d}", product.SubscriptionExpirationDate); break; case InAppProductType.FreeSubscription: // Show it never expires AvailableQuantity.Hidden = false; AvailableQuantity.Text = "Unlimited"; break; case InAppProductType.NonConsumable: if (Product.Downloadable) { // Use quantity to show download state if (Product.NewContentAvailable) { AvailableQuantity.Text = string.Format("v{0} Available", Product.DownloadableContentVersion); // Display update button and wire it up _displayContent = false; UpdateButton.Hidden = _purchaseManager.DownloadInProgress; UpdateButton.SetTitle("Update", UIControlState.Normal); WireupUpdateButton(); } else if (Product.ContentDownloaded) { AvailableQuantity.Text = string.Format("Ready v{0}", Product.DownloadableContentVersion); // Display button _displayContent = true; UpdateButton.Hidden = false; UpdateButton.SetTitle("Show", UIControlState.Normal); WireupUpdateButton(); } else { AvailableQuantity.Text = "Awaiting Content"; // Display update button and wire it up _displayContent = false; UpdateButton.Hidden = _purchaseManager.DownloadInProgress; UpdateButton.SetTitle("Get", UIControlState.Normal); WireupUpdateButton(); } AvailableQuantity.Hidden = false; } else { // Not downloadable, hide quantity AvailableQuantity.Hidden = true; } break; default: AvailableQuantity.Hidden = true; break; } }
/// <summary> /// Initializes a new instance of the <see cref="InAppPurchaseTest.PurchaseTableSource"/> class. /// </summary> /// <param name="controller">Controller.</param> public PurchaseTableSource(PurchaseTableViewController controller) { // Initialize _controller = controller; }