Exemplo n.º 1
0
        // Unity IAP framework will call this method after Initialize method regardless.
        public void RetrieveProducts(ReadOnlyCollection <ProductDefinition> products)
        {
            _billingClientStateListener = new BillingClientStateListener();
            // Retry connection when Play Billing Service is disconnected.
            _billingClientStateListener.OnBillingServiceDisconnected += () =>
            {
                _billingUtil.LogWarningFormat("Service disconnected, retrying connection...");
                EndConnection();
                InstantiateBillingClientAndMakeConnection();
            };
            _billingClientStateListener.OnBillingSetupFinished += (billingResult) =>
            {
                MarkBillingClientStartConnectionCallComplete(billingResult);
                if (_billingClientReady)
                {
                    _inventory.UpdateCatalog(products);

                    // Kick off tasks to retrieve products information on the main thread.
                    _billingUtil.RunOnMainThread(() =>
                                                 RetrieveProductsInternal(products));
                }
                else
                {
                    _billingUtil.LogWarningFormat("Google Play Store: play billing service unavailable!");
                    _billingUtil.RunOnMainThread(() =>
                                                 _callback.OnSetupFailed(InitializationFailureReason.PurchasingUnavailable));
                }
            };

            InstantiateBillingClientAndMakeConnection();
        }
Exemplo n.º 2
0
        // Unity IAP framework will call this method after Initialize method regardless.
        public void RetrieveProducts(ReadOnlyCollection <ProductDefinition> products)
        {
            if (!_billingClientReady)
            {
                _billingUtil.LogWarningFormat("Google Play Store: play billing service unavailable!");
                _billingUtil.RunOnMainThread(() =>
                                             _callback.OnSetupFailed(InitializationFailureReason.PurchasingUnavailable));
                return;
            }

            _inventory.UpdateCatalog(products);

            // Run tasks to retrieve products information and trigger callback when all of them finished.
            RetrieveProductsInternal(products);
        }