Unity Bug, Unity iAP stuck!

Unity Bug, Unity iAP stuck!

Unity has a recent bug in its iAP. It, sometimes, gets stuck when we repeat a purchase.

Try closing the application after purchasing a consumable item but before the purchase confirmation. Now again attempt the purchase. A popup is shown that the iAP has already been bought and it will be restored for free. It is suggested to restore a consumable item!!

You get this bug if you are using Unity codeless iAP and it cannot be solved without writing a bit of code. Therefore, you would have to switch to iAP with code which is pretty easy. Here, you manually initialize iAP through a script. For example, see here.

For resolving the bug, all you need is to edit the OnInitialized function as follows:

        public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            // Purchasing has succeeded initializing. Collect our Purchasing references.
            // Overall Purchasing system, configured with products for this application.
            m_StoreController = controller;
            // Store specific subsystem, for accessing device-specific store features.
            m_StoreExtensionProvider = extensions;

            foreach (var product in m_StoreController.products.all)
            {
                m_StoreController.ConfirmPendingPurchase(product);
            }
        }

Using the above lines of code, the ProcessPurchase function would be invoked automatically for the purchases that are still pending. Therefore, the purchase will be completed and the user will get what he had paid for. Also, he can make the purchase again as no iAP is now stuck.

Bug Resolved! Hope you are no longer stuck on iAP! Happy Coding!

Share This Post

Post Comment