/// <summary> /// iOS 6 SKStoreProductViewController display /// </summary> void Buy(int productId) { Console.WriteLine("Buy " + productId); var spp = new StoreProductParameters(productId); var productViewController = new SKStoreProductViewController(); productViewController.Finished += (sender, err) => { Console.WriteLine("ProductViewDelegate Finished"); // Apple's docs says to use this this.DismissModalViewControllerAnimated(true); }; productViewController.LoadProduct(spp, (ok, err) => { Console.WriteLine("load product"); if (ok) { PresentModalViewController(productViewController, true); } else { Console.WriteLine(" failed "); if (err != null) { Console.WriteLine(" with error " + err); } } }); }
/// <summary> /// Presents the native App Store interface with the product identified by its iTunes ID. /// <p></p> /// This is available in iOS 6.0 and later. /// </summary> /// <param name="iTunesID">The iTunes ID that identifies the product to show.</param> public static void ShowStore(string iTunesID) { _storeViewController = new SKStoreProductViewController(); // vc.Delegate = StoreProductViewControllerDelegate.instance; var param = new Dictionary <object, object>(); param[SKStoreProductViewController.SKStoreProductParameterITunesItemIdentifier] = iTunesID; _storeViewController.LoadProduct(param, delegate(bool result, NSError error) { if (result) { _storeViewController.DidFinish += _ShowStoreDidFinish; UIApplication.deviceRootViewController.PresentViewController(_storeViewController, true, null); } else { if (_storeViewLoadFailedHandlers != null) { _storeViewLoadFailedHandlers(null, new U3DXTErrorEventArgs(error)); } _storeViewController = null; } }); }
/// <summary> /// iOS 6 SKStoreProductViewController display /// </summary> void Buy (int productId) { Console.WriteLine ("Buy " + productId); var spp = new StoreProductParameters(productId); var productViewController = new SKStoreProductViewController (); productViewController.Finished += (sender, err) => { Console.WriteLine ("ProductViewDelegate Finished"); // Apple's docs says to use this this.DismissModalViewController (true); }; productViewController.LoadProduct (spp, (ok, err) => { Console.WriteLine ("load product"); if (ok) { PresentModalViewController (productViewController, true); } else { Console.WriteLine (" failed "); if (err != null) Console.WriteLine (" with error " + err); } }); }