Esempio n. 1
0
        void InstantiateBillingClientAndMakeConnection()
        {
            _billingClientStateListener = new BillingClientStateListener();
            _billingClientStateListener.OnBillingServiceDisconnected += () => {
                Debug.Log("Service disconnected");
                EndConnection();
                //InstantiateBillingClientAndMakeConnection();
            };

            _billingClientStateListener.OnBillingSetupFinished += (billingResult) => MarkBillingClientStartConnectionCallComplete(billingResult);

            // Set ready flag to false as this action could be triggered when in-app billing service is disconnected.
            _billingClientReady = false;

            var context = JniUtils.GetApplicationContext();

            _billingClient = new AndroidJavaObject("com.android.billingclient.api.BillingClientImpl",
                                                   "3.0.0-unity");

            _billingClient.Call(
                "initialize",
                context,
                null,
                _deferredPurchasesEnabled);

            _billingClient.Call("startConnection", _billingClientStateListener);
        }
Esempio n. 2
0
        private void InstantiateBillingClientAndMakeConnection()
        {
            // Set ready flag to false as this action could be triggered when in-app billing service is disconnected.
            _billingClientReady = false;

            var context = JniUtils.GetApplicationContext();

            _billingClient = new AndroidJavaObject(Constants.BillingClient,
                                                   Constants.Version);

            var purchaseUpdatedListener = new PurchasesUpdatedListener();

            purchaseUpdatedListener.OnPurchasesUpdated += ParsePurchaseResult;

            _billingClient.Call(
                Constants.BillingClientSetUpMethod,
                context,
                purchaseUpdatedListener,
                _deferredPurchasesEnabled);

            _billingClient.Call(Constants.BillingClientStartConnectionMethod, _billingClientStateListener);
        }