Quantcast
Channel: Questions in topic: "iap"
Viewing all articles
Browse latest Browse all 595

Unity's IAP code explained

$
0
0
Hello, I am porting my successful android game to iOS, all works but I have a little problem with IAPs (i am using official unitys IAP plugin) When testing on my iPhone, iap works, but apples confirm purchase window appears little bit delayed after the click (like 1-2 seconds, unlike on android where it pop ups straight away) so sometimes user can click it multiple times which leads to opening confirm popup multiple times. I check some other top apps on ios, and what they does is displaying some sort of popup like "waiting for transaction" before apples confirm transaction window appears, i want to to the same, just not sure if I understand unitys iap code properly, i have added capital letters comment in the code below to show how i think i would do it, would be grateful if someone can look and confirm if it is correct: void BuyProductID(string productId) { // If Purchasing has been initialized ... if (IsInitialized()) { // -<<<<<<<<<< DISPLAY MY POPUP "WAITING FOR TRANSACTION" >>>>>>>>>>>>>>>>>>>>> // ... look up the Product reference with the general product identifier and the Purchasing // system's products collection. Product product = m_StoreController.products.WithID(productId); // If the look up found a product for this device's store and that product is ready to be sold ... if (product != null && product.availableToPurchase) { Debug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id)); // ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed // asynchronously. m_StoreController.InitiatePurchase(product); // CLOSE MY POPUP BECAUSE APPLES CONFIRM POPUP IS NOW VISIBLE!! } // Otherwise ... else { // ... report the product look-up failure situation Debug.Log("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase"); // CLOSE MY POPUP BECAUSE OF ERROR } } // Otherwise ... else { // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or // retrying initiailization. Debug.Log("BuyProductID FAIL. Not initialized."); } } Also my last question would be, should i enable IN APP PURCHASE capability in XCODE capabilities? Regards.

Viewing all articles
Browse latest Browse all 595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>