public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{


			// create a new window instance based on the screen size
			Window = new UIWindow (UIScreen.MainScreen.Bounds);

			viewController = new ThingViewController();

			// If you have defined a view, add it here:
			//window.AddSubview (navigationController.View);
			Window.RootViewController = viewController;


			// Initialize the In App Purchase Manager
			PurchaseManager.simulateiTunesAppStore = false; // use the real thing
			PurchaseManager.PublicKey = "ASDFASDFASDF";
			PurchaseManager.automaticPersistenceType = InAppPurchasePersistenceType.UserDefaults;



			// Warn user that the store is not available
			if (PurchaseManager.canMakePayments) {
				Console.WriteLine ("Xamarin.InAppBilling: User can make payments to iTunes App Store.");
			} else {
				//Display Alert Dialog Box
				using(var alert = new UIAlertView("Xamarin.InAppBilling", "Sorry but you cannot make purchases from the In App Billing store. Please try again later.", null, "OK", null))
				{
					alert.Show();	
				}
			}

			// Show any invalid product queries
			PurchaseManager.ReceivedInvalidProducts += (productIDs) => {
				// Display any invalid product IDs to the console
				Console.WriteLine("PurchaseManager.ReceivedInvalidProducts - The following IDs were rejected by the iTunes App Store:");
				foreach(string ID in productIDs){
					Console.WriteLine(ID);
				}
			};

			// Report the results of the user restoring previous purchases
			PurchaseManager.InAppPurchasesRestored += (count) => {
				Console.WriteLine("PurchaseManager.InAppPurchasesRestored");
			};

			// Report miscellanous processing errors
			PurchaseManager.InAppPurchaseProcessingError += (message) => {
				Console.WriteLine("PurchaseManager.InAppPurchaseProcessingError " + message);
			};

			// Report any issues with persistence
			PurchaseManager.InAppProductPersistenceError += (message) => {
				Console.WriteLine("PurchaseManager.InAppProductPersistenceError");
			};

			PurchaseManager.TransactionsRemovedFromQueue += (transactions) => {
				Console.WriteLine("PurchaseManager.TransactionsRemovedFromQueue " + transactions.Count());
				foreach (var t in transactions){
					Console.WriteLine("--- " + t.Payment.ProductIdentifier);
				}

			};

			viewController.AttachToPurchaseManager (PurchaseManager);

			// make the window visible
			Window.MakeKeyAndVisible ();

			return true;
		}
示例#2
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // create a new window instance based on the screen size
            Window = new UIWindow(UIScreen.MainScreen.Bounds);

            viewController = new ThingViewController();

            // If you have defined a view, add it here:
            //window.AddSubview (navigationController.View);
            Window.RootViewController = viewController;


            // Initialize the In App Purchase Manager
            PurchaseManager.simulateiTunesAppStore = false;             // use the real thing
            PurchaseManager.PublicKey = "ASDFASDFASDF";
            PurchaseManager.automaticPersistenceType = InAppPurchasePersistenceType.UserDefaults;



            // Warn user that the store is not available
            if (PurchaseManager.canMakePayments)
            {
                Console.WriteLine("Xamarin.InAppBilling: User can make payments to iTunes App Store.");
            }
            else
            {
                //Display Alert Dialog Box
                using (var alert = new UIAlertView("Xamarin.InAppBilling", "Sorry but you cannot make purchases from the In App Billing store. Please try again later.", null, "OK", null))
                {
                    alert.Show();
                }
            }

            // Show any invalid product queries
            PurchaseManager.ReceivedInvalidProducts += (productIDs) => {
                // Display any invalid product IDs to the console
                Console.WriteLine("PurchaseManager.ReceivedInvalidProducts - The following IDs were rejected by the iTunes App Store:");
                foreach (string ID in productIDs)
                {
                    Console.WriteLine(ID);
                }
            };

            // Report the results of the user restoring previous purchases
            PurchaseManager.InAppPurchasesRestored += (count) => {
                Console.WriteLine("PurchaseManager.InAppPurchasesRestored");
            };

            // Report miscellanous processing errors
            PurchaseManager.InAppPurchaseProcessingError += (message) => {
                Console.WriteLine("PurchaseManager.InAppPurchaseProcessingError " + message);
            };

            // Report any issues with persistence
            PurchaseManager.InAppProductPersistenceError += (message) => {
                Console.WriteLine("PurchaseManager.InAppProductPersistenceError");
            };

            PurchaseManager.TransactionsRemovedFromQueue += (transactions) => {
                Console.WriteLine("PurchaseManager.TransactionsRemovedFromQueue " + transactions.Count());
                foreach (var t in transactions)
                {
                    Console.WriteLine("--- " + t.Payment.ProductIdentifier);
                }
            };

            viewController.AttachToPurchaseManager(PurchaseManager);

            // make the window visible
            Window.MakeKeyAndVisible();

            return(true);
        }